-
-
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
support cstring in case
#20130
support cstring in case
#20130
Conversation
for now just converts to string on C backend
Does it works when the |
I thought it would be complicated to make it work but it's not |
This is awesome! Since this will be in version 2.0 it doesn't need an experimental switch. It does need a changelog entry though and documentation updates. |
Done |
Thanks for your hard work on this PR! Hint: mm: orc; threads: on; opt: speed; options: -d:release |
* implement case for cstring for now just converts to string on C backend * custom implementation for cstring * remove leftover * revert even more * add nil + fix packages weird variant literal bug * update docs
fixes #11422, refs #8336/#8333, refs #20130 The compiler generates conversion nodes *after* evaluating the branches of case statements as constants, the reasoning is that case branches accept constants of different types, like arrays or sets. But this means that conversion nodes that need to be evaluated like converter calls don't get evaluated as a constant for codegen. #8336 fixed this by re-evaluating the node if an `nkHiddenCallConv` was created, and in #20130 this logic also had to be added for `nkHiddenStdConv` for cstrings. This logic was only for single case elements, it has now been added to range elements as well to fix #11422. Additionally, all conversion nodes are now evaluated for simplicity, but maybe this won't pass CI.
closes nim-lang/RFCs#350
Again a bit sloppy, but should work.
Can add experimental switch or whatever if desired.