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

Missing compile error for enum(u0){a,_} #19856

Open
rohlem opened this issue May 4, 2024 · 0 comments
Open

Missing compile error for enum(u0){a,_} #19856

rohlem opened this issue May 4, 2024 · 0 comments
Labels
bug Observed behavior contradicts documented or intended behavior

Comments

@rohlem
Copy link
Contributor

rohlem commented May 4, 2024

Zig Version

0.13.0-dev.46+3648d7df1, 0.12.0-dev.3182+f3227598e

Steps to Reproduce and Observed Behavior

The compiler currently errors when an enum is declared as non-exhaustive (with pseudo-member _) while specifying every possible value as state.
However, this error doesn't trigger when the backing type is a zero-bit type (u0 or i0):

comptime {
    _ = enum(u0) { a, _ };
    _ = enum(u1) { a, b, _ };
}
main.zig:3:9: error: non-exhaustive enum specifies every value
    _ = enum(u1) { a, b, _ };
        ^~~~~~~~~~~~~~~~~~~~

Expected Behavior

main.zig:2:9: error: non-exhaustive enum specifies every value
    _ = enum(u0) { a, _ };
        ^~~~~~~~~~~~~~~~~

Note that the same error is present for instantiation via @Type; I assume the compiler-internal code for both places is shared, so that a fix would apply to both scenarios.

@rohlem rohlem added the bug Observed behavior contradicts documented or intended behavior label May 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Observed behavior contradicts documented or intended behavior
Projects
None yet
Development

No branches or pull requests

1 participant