aboutsummaryrefslogtreecommitdiff
path: root/test/cases/assert_function.8.zig
blob: 02b486a8cb2bc39da71f8ef7c27909c4dcbc23d2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
extern "c" fn write(c_int, usize, usize) usize;

pub fn main() void {
    var i: u32 = 0;
    inline while (i < 4) : (i += 1) print();
    assert(i == 4);
}

fn print() void {
    _ = write(1, @intFromPtr("hello\n"), 6);
}

pub fn assert(ok: bool) void {
    if (!ok) unreachable; // assertion failure
}

// error
//
// :5:21: error: unable to resolve comptime value
// :5:21: note: condition in comptime branch must be comptime-known