-
-
Notifications
You must be signed in to change notification settings - Fork 2.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
Enum value wrong in nested switch #17718
Comments
I did a few more tests: The code does exhibit the bug only when run in the browser in wasm. I suspected some weird memory corruption, so I replaced the line with |
Ok, I discovered something. I noticed that the enum is actually correct up to 4 and then it starts back to 0. My It made me realize that the enum underlying type must be incorrectly inferred under some circumstances. If I explicitly specify // from
pub const Id = union(enum) {
// to
pub const Id = union(enum(u8)) { The bug does not happen. |
Cannot reproduce on
|
Yes I cannot reproduce it outside of the browser with my own code base. |
Ah, I didn't notice the line about wasm. Either way I can't reproduce it using |
Yeah I cannot reproduce it with command line |
I spent the day trying to reproduce it, without success. I tried to compare the |
Zig Version
0.12.0-dev.1270+6c9d34bce
Steps to Reproduce and Observed Behavior
I have code similar to this: (I was unable to reproduce the bug with a minimal example)
The tag should be the same both time, it should print
tag A 1
andtag B 1
.But in my code, the second one is 0.
Here is the actual code and it's output:
If I do
.id => |*id|
andswitch (id.*)
the bug does not occurs.Actual code is built for wasm.
Expected Behavior
Enum tag should be the same within the switch.
The text was updated successfully, but these errors were encountered: