aboutsummaryrefslogtreecommitdiff
path: root/test/cases/compile_errors/add_sat_on_undefined_value.zig
blob: a0648e1a0f2c50672f42c2f14678caeb9c714d39 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
comptime {
    const undef: i64 = undefined;
    const not_undef: i64 = 32;

    // If either of the operands are zero, then the other operand is returned.
    @compileLog(undef +| 0);
    @compileLog(not_undef +| 0);
    @compileLog(0 +| undef);
    @compileLog(0 +| not_undef);
    // If either of the operands are undefined, the result is undefined.
    @compileLog(undef +| 1);
    @compileLog(not_undef +| 1);
    @compileLog(1 +| undef);
    @compileLog(1 +| not_undef);
}

// error
//
// :6:5: error: found compile log statement
//
// Compile Log Output:
// @as(i64, undefined)
// @as(i64, 32)
// @as(i64, undefined)
// @as(i64, 32)
// @as(i64, undefined)
// @as(i64, 33)
// @as(i64, undefined)
// @as(i64, 33)