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 · May be fixed by #21374
Open

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

rohlem opened this issue May 4, 2024 · 0 comments · May be fixed by #21374
Labels
bug Observed behavior contradicts documented or intended behavior frontend Tokenization, parsing, AstGen, Sema, and Liveness.
Milestone

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
@Vexu Vexu added the frontend Tokenization, parsing, AstGen, Sema, and Liveness. label May 31, 2024
@Vexu Vexu added this to the 0.14.0 milestone May 31, 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 frontend Tokenization, parsing, AstGen, Sema, and Liveness.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants