-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Remove forward references from binding patterns #4494
Conversation
This is primarily to free up space in the BindingPattern insts, but as a side effect it moves the link between BindingPattern and its BindName out of the SemIR, and into a transient data structure in Context.
This PR seems to fix a pre-existing bug where we were materializing redundant copies of |
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.
For the weird bug fix: it looks like we were previously including the bind_name_id
in the canonical identity of a SymbolicBindingPattern
, so we got different constant values for different bind_name_id
s -- and you can't see the difference because the formatter was not printing the MatchingInstId
field.
toolchain/check/pattern_match.cpp
Outdated
binding_pattern.bind_name_id); | ||
auto bind_name_id = context.bind_name_cache() | ||
.Lookup(binding_pattern.entity_name_id) | ||
.value(); |
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.
Does it make sense to remove the entry from the cache 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 think removing it outright could mask bugs, by allowing it to be re-inserted (which should never happen), but we can at least invalidate the entry. Done.
Co-authored-by: Richard Smith <[email protected]>
This is primarily to free up space in the BindingPattern insts, but as a side effect it moves the link between BindingPattern and its BindName out of the SemIR, and into a transient data structure in Context.