Skip to content

Assorted bugfixes for new analysis #14658

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Oct 30, 2023
Merged

Assorted bugfixes for new analysis #14658

merged 6 commits into from
Oct 30, 2023

Conversation

cameel
Copy link
Member

@cameel cameel commented Oct 30, 2023

Moved here from my fixups into newAnalysis:

  1. Two Function types being created, instead of Function and Itself.
  2. resolveRecursive() not resolving type variables.
  3. index() being used on the Type variant rather than TypeVariable
    • Should were rename index to id? The current name seems very prone to this kind of error.
  4. Sorts being printed twice by DebugWarner.
  5. Unnecessary sort comparison in unify() - should have been an assert.
  6. uint64_t instead of size_t used for the index in TypeEnvironment::fresh().
    • This is the only use I found and it's size_t everywhere else. This is part of compiler output though, so a portable type like uint64_t is probably a better choice though. Should we switch?

@cameel cameel requested a review from ekpyron October 30, 2023 16:41
@cameel cameel self-assigned this Oct 30, 2023
Copy link
Member

@ekpyron ekpyron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, these are all very much uncontroversial and we agreed on more or less all of them before, so I didn't even expect them to be pulled out again - fine to merge these back in :-).

if (sort.classes.size() != 1 || *sort.classes.begin() != m_analysis.typeSystem().primitiveClass(PrimitiveClass::Type))
sortString = ":" + TypeSystemHelpers{m_analysis.typeSystem()}.sortToString(m_analysis.typeSystem().env().sort(type));
std::optional<Type> const& inferredType = m_analysis.annotation<TypeInference>(_node).type;
if (inferredType.has_value())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As for random style remarks: I find .has_value() on optionals horrible myself personally :-D... but it doesn't matter at all, ultimately everybody can read both, so I don't bother pushing my own preferred style through.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For me it's if (inferredType) that's horrible. It does not read like a condition at all. It forces me stop and think in which way this can be interpreted as a boolean, while on seeing inferredType.has_value() I immediately know it's an optional and can move on smoothly. I'm really not sure why people don't find this jarring.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's my point, though - it's purely subjective and we spend way too much time and effort in general in flipping back and forth around purely subjective taste that has no actual bearing on overall readability.

Copy link
Member

@ekpyron ekpyron Oct 31, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As in: I find this significantly less readable with .has_value() than without - and I don't buy that it'd be worse for you to read it without that than it is for me to read it with that - we should just generally have a bit more flexibility around stuff like this (that would already significantly reduce number of comments on PRs).

@cameel
Copy link
Member Author

cameel commented Oct 30, 2023

Yeah, these are all very much uncontroversial and we agreed on more or less all of them before, so I didn't even expect them to be pulled out again - fine to merge these back in :-)

Well, I thought you wanted all of the fixups removed from the base branch :)

@cameel cameel merged commit 3078a9f into newAnalysis Oct 30, 2023
@cameel cameel deleted the new-analysis-bugfixes branch October 30, 2023 17:39
cameel added a commit that referenced this pull request Dec 8, 2023
cameel added a commit that referenced this pull request Dec 13, 2023
cameel added a commit that referenced this pull request Dec 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants