-
-
Notifications
You must be signed in to change notification settings - Fork 671
feat: support more types in switch statements #2926
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
feat: support more types in switch statements #2926
Conversation
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.
as does not use string pool..so it is impossible to compare two string directly with ptr. string.eq must be used for each check.
... oh. I see. I was thrown off because the naive test passed, but this one fails: assert(doSwitchString("o" + "n" + "e") == 1); because the concatenated resulting string is in a different variable and thus a different pointer than the I'll add a special case for strings. I think it should be good for the rest though. |
I wonder if this should just be using the |
Working on a revision. I think I can reuse some existing code. I found that string equality isn't handled by the Much of the logic to determine whether to call |
This is now updated with the revisions. I've split the existing |
@HerrCai0907 any other adjustments you would like? |
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.
LGTM.
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.
LGTM. And wow, these method names (compileCommutativeCompareBinaryExpressionFromParts
) are starting to get longer and longer 😛
153ca02
to
9029772
Compare
Fixes #2919
Fixes #648
Changes proposed in this pull request:
switch
statement with certain types.I've reused the existing equality comparison logic, so any behavior for
==
is retained for switch cases, including overloads, etc.