-
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
[NFC] Convert NameScope from struct to class #4623
Conversation
This is a preparation change for adding name poisoning support, which is expected to require more elaborate logic around NameScope since a name can be not defined yet, defined, or poisoned. This change has the following benefits: * names_ and name_map_ are internal to NameScope and are guaranteed to match. * extended_scopes and import_ir_scopes can not be manipulated (only new scopes can be added). * inst_id, name_id and parent_scope_id are constants. * has_error can only be mutated from false to true.
* Make EntryId a struct that inherits from IdBase. * Return ArrayRef and not const vector &. * Rename AddImportIrScope() to AddImportIRScope() to be consistent with ImportIRId and SemIR.
…ope as a struct to make it simpler
…tion that generates it
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.
Thanks! As noted before, I'm good with the general direction here towards a class, I agree it'll probably help with name poisoning (plus, we want to keep abstracting out name lookup logic in general).
…we encounter errors before
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.
Thanks! The changes look good, I'm going to go ahead and try to merge this.
Thanks @jonmeow ! |
Thanks for the note, I missed a button due to a GH beta UI. But also it looks like your PR is failing against trunk. The issue looks basic so I'll fix that for now; we tend to give out contributor privs to ease this workflow issue. |
daba2c7
This is a preparation change for adding name poisoning support (#4622), which is expected to require more elaborate logic around NameScope since a name can be not defined yet, defined, or poisoned.
The API separates looking up a name from getting the full entry since we have cases where the entries are invalidated between the time we're looking for the name and when we access (and sometimes modify) the entry.
This change has the following benefits:
names
andname_map
are internal toNameScope
and are guaranteed to match.extended_scopes
andimport_ir_scopes
can not be manipulated (only new scopes can be added).inst_id
,name_id
andparent_scope_id
are constants.has_error
can only be mutated from false to true.