aboutsummaryrefslogtreecommitdiff
path: root/test/cases/compile_errors/non-const_switch_number_literal.zig
blob: 01e31bb92c55710aec5b295ced2bb0c89ae49e2c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
export fn foo() void {
    const x = switch (bar()) {
        1, 2 => 1,
        3, 4 => 2,
        else => 3,
    };
    _ = x;
}
fn bar() i32 {
    return 2;
}

// error
// backend=stage2
// target=native
//
// :2:15: error: value with comptime only type 'comptime_int' depends on runtime control flow
// :2:26: note: runtime control flow here