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

Labeled switch causes all switch prongs to be analyzed #22450

Open
chadwain opened this issue Jan 9, 2025 · 0 comments
Open

Labeled switch causes all switch prongs to be analyzed #22450

chadwain opened this issue Jan 9, 2025 · 0 comments
Labels
bug Observed behavior contradicts documented or intended behavior

Comments

@chadwain
Copy link
Contributor

chadwain commented Jan 9, 2025

Zig Version

0.14.0-dev.2577+271452d22

Steps to Reproduce and Observed Behavior

pub fn main() void {
    const x: u2 = 0;
    sw: switch (x) {
        0 => {},
        1 => continue :sw 0,
        2, 3 => @compileError("bad"),
    }
}
test.zig:6:17: error: bad
        2, 3 => @compileError("bad"),
                ^~~~~~~~~~~~~~~~~~~~

Expected Behavior

No compilation error, as comptime-known unreachable switch prongs should not be analyzed.

@chadwain chadwain added the bug Observed behavior contradicts documented or intended behavior label Jan 9, 2025
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