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

always lookup pure enum symbols if expected type is enum #23976

Merged
merged 1 commit into from
Aug 17, 2024

Conversation

metagn
Copy link
Collaborator

@metagn metagn commented Aug 17, 2024

fixes #23689

Normally pure enum symbols only "exist" in lookup if nothing else with the same name is in scope. But if an expression is expected to be an enum type, we know that ambiguity can be resolved between different symbols based on their type, so we can include the normally inaccessible pure enum fields in the ambiguity resolution in the case that the expected enum type is actually a pure enum. This handles the use case in the issue of the type inference for enums reverted in #23588.

I know pure enums are supposed to be on their way out so this might seem excessive, but the pure pragma can't be removed in the code in the issue due to a redefinition error, they have to be separated into different modules. Normal enums can still resolve the ambiguity here though. I always think about making a list of all the remaining use cases for pure enums and I always forget.

Will close #23694 if CI passes

@Araq Araq merged commit a354b18 into nim-lang:devel Aug 17, 2024
18 checks passed
Copy link
Contributor

Thanks for your hard work on this PR!
The lines below are statistics of the Nim compiler built from a354b18

Hint: mm: orc; opt: speed; options: -d:release
173444 lines; 8.103s; 654.555MiB peakmem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants