aboutsummaryrefslogtreecommitdiff
path: root/test/cases/safety/@enumFromInt truncated bits - nonexhaustive.zig
blob: 16e4699478c5f0448211fbe855a1eecadab0fd6e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
const std = @import("std");

pub fn panic(message: []const u8, _: ?*std.builtin.StackTrace, _: ?usize) noreturn {
    if (std.mem.eql(u8, message, "invalid enum value")) {
        std.process.exit(0);
    }
    std.process.exit(1);
}

pub fn main() u8 {
    var num: u8 = undefined;
    num = 250;

    const E = enum(u6) { _ };
    const invalid: E = @enumFromInt(num);
    _ = invalid;

    return 1;
}

// run
// backend=selfhosted,llvm
// target=x86_64-linux