Skip to content
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

Merged
merged 4 commits into from
Nov 8, 2024

Conversation

geoffromer
Copy link
Contributor

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 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.
@geoffromer
Copy link
Contributor Author

This PR seems to fix a pre-existing bug where we were materializing redundant copies of symbolic_binding_pattern insts, but for the life of me I can't explain where the bug is or how this PR could possibly have fixed it.

Copy link
Contributor

@zygoloid zygoloid left a 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_ids -- and you can't see the difference because the formatter was not printing the MatchingInstId field.

toolchain/check/handle_binding_pattern.cpp Outdated Show resolved Hide resolved
binding_pattern.bind_name_id);
auto bind_name_id = context.bind_name_cache()
.Lookup(binding_pattern.entity_name_id)
.value();
Copy link
Contributor

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?

Copy link
Contributor Author

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.

@geoffromer geoffromer added this pull request to the merge queue Nov 8, 2024
Merged via the queue into carbon-language:trunk with commit 5759ad8 Nov 8, 2024
8 checks passed
@geoffromer geoffromer deleted the bind-name branch November 8, 2024 20:40
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