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

Special-case api/impl implicit imports and verify relevant redeclarations. #3843

Merged
merged 2 commits into from
Apr 4, 2024

Conversation

jonmeow
Copy link
Contributor

@jonmeow jonmeow commented Apr 2, 2024

Adds ImportIRId::ApiForImpl to reserve a specific slot for the api import, so that the code can trivially determine whether an import is from the same library. This is then used for merging function declarations, because the rules for redeclarations in the same library slightly differ as compared to other imports (note they're also not identical to same-file rules).

The main thing this leaves from the recent #3762 is verifying that entities forward declared in the impl file are also defined, but that's not in-scope for merging; it's moreso post-checking validation.

Note, a lot of our invalid <entity> ID comments in ids.h were incorrectly copy-pasted, so I've cut <entity>.

@github-actions github-actions bot requested a review from josh11b April 2, 2024 22:32
Copy link
Contributor

@josh11b josh11b left a comment

Choose a reason for hiding this comment

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

I'm not super familiar with this code, so you may want to get another review, but I didn't see any problems.

@jonmeow jonmeow requested a review from zygoloid April 3, 2024 23:46
Comment on lines 18 to 19
// typically only be used for the ImportIRId, but we only resolve that if
// needed.
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't understand what the part of this second sentence after the comma is telling me. What do we only resolve if needed -- the ImportIRId? If so, what does it mean to resolve an ImportIRId?

Copy link
Contributor Author

@jonmeow jonmeow Apr 4, 2024

Choose a reason for hiding this comment

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

rephrasing: resolve that -> load it

ImportIRInstId is a reference to an ImportIRId and an InstId. Only the ImportIRId should be used in this context, but it's not actually available unless the ImportIRInst that contains the actual ImportIRId is loaded/resolved.

@jonmeow jonmeow enabled auto-merge April 4, 2024 15:57
@jonmeow jonmeow added this pull request to the merge queue Apr 4, 2024
Merged via the queue into carbon-language:trunk with commit 2361830 Apr 4, 2024
7 checks passed
@jonmeow jonmeow deleted the api-id branch April 4, 2024 16:11
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.

3 participants