Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please move this
if
until after thestructurally_resolve_type
as it can otherwise miss info about the type of expected.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new tests previously failed because
structurally_resolve_type
returned an inference error.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah, I guess we need
try_structurally_resolve_type
here 😅There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not convinced this is necessary. We only get into the
demand_eqtype
call when the pattern is irrefutable, how exactly would trying to structurally resolve the type help here? Afaict either there's a type annotation and we ignore all the logic introduced in this PR or there is none, in which caseexpected
is just an unresolvable type variable afaict. Since we have to resolve the type after thedemand_eqtype
call anyway (since we still have to resolve the inner type after hinting that we're looking for[_; n]
) I don't see why we wanttry_structurally_resolve_type
first. Can you explain why that would be helpful/necessary?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we get into the
demand_eqtype
call when the pattern is irrefutable and the expected type is an inference variable. Whether the expected type is an inference variable can depend on structrally resolving it.I can't imagine how you'd get to a point where it matters, but generally looking at the
kind()
of a type and then usingstructurally_resolve
orshallow_resolve
or whatever is always sus. Either theresolve
is a noop, in which case it should be removed, or it can change thekind()
of the type, in which case looking at the type before the resovle call is buggy.Ah, nearly forgot: can you add tests for destructing assignments, i.e. what happens with the following
we should treat these as also being irrefutable and this example should compile i think