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

stricter set type match, implicit conversion for literals #24176

Merged
merged 7 commits into from
Oct 3, 2024

Conversation

metagn
Copy link
Collaborator

@metagn metagn commented Sep 25, 2024

fixes #18396, fixes #20142

Set types with base types matching less than a generic match (so subrange matches, conversion matches, int conversion matches) are now considered mismatching, as their representation is different on the backends (except VM and JS), causing codegen issues. An exception is granted for set literal types, which now implicitly convert each element to the matched base type, so things like s == {'a', 'b'} are still possible where s is set[range['a'..'z']]. Also every conversion match in this case is unified under the normal "conversion" match, so a literal doesn't match one set type better than the other, unless it's equal.

However {'a', 'b'} == s or {'a', 'b'} - s etc is now not possible. when it used to work in the VM. So this is somewhat breaking, and needs a changelog entry.

@metagn metagn changed the title test stricter set type match without literal inference stricter set type match, implicit conversion for literals Sep 26, 2024
@metagn metagn marked this pull request as ready for review September 26, 2024 15:07
@Araq Araq merged commit 7dfadb8 into nim-lang:devel Oct 3, 2024
19 checks passed
Copy link
Contributor

github-actions bot commented Oct 3, 2024

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

Hint: mm: orc; opt: speed; options: -d:release
174751 lines; 8.218s; 653.93MiB 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