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

invalid enum value safety check should include the tried value #13351

Open
nektro opened this issue Oct 29, 2022 · 0 comments
Open

invalid enum value safety check should include the tried value #13351

nektro opened this issue Oct 29, 2022 · 0 comments
Labels
enhancement Solving this issue will likely involve adding new logic or components to the codebase.
Milestone

Comments

@nektro
Copy link
Contributor

nektro commented Oct 29, 2022

Zig Version

0.10.0-dev.4620+c389f8800

Steps to Reproduce and Observed Behavior

const E = enum(u8) {
    a,
    b,
    c,
    d,
};

pub fn main() void {
    var a: u8 = 20;
    _ = @intToEnum(E, a);
}
thread 3390539 panic: invalid enum value
./test.zig:10:5: 0x2101ce in main (test)
    _ = @intToEnum(E, a);
    ^
...

Expected Behavior

thread 3390539 panic: invalid enum value, found 20
./test.zig:10:5: 0x2101ce in main (test)
    _ = @intToEnum(E, a);
    ^
...
@nektro nektro added the bug Observed behavior contradicts documented or intended behavior label Oct 29, 2022
@andrewrk andrewrk added the enhancement Solving this issue will likely involve adding new logic or components to the codebase. label Oct 30, 2022
@andrewrk andrewrk added this to the 0.12.0 milestone Oct 30, 2022
@andrewrk andrewrk removed the bug Observed behavior contradicts documented or intended behavior label Oct 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Solving this issue will likely involve adding new logic or components to the codebase.
Projects
None yet
Development

No branches or pull requests

2 participants