unreachable

    In ReleaseFast mode, the optimizer uses the assumption that unreachable code will never be hit to perform optimizations. However, zig test even in ReleaseFast mode still emits unreachable as calls to panic.

    1. $ zig test test.zig
    2. 1/1 test "basic math"...OK

    In fact, this is how assert is implemented:

    1. $ zig test test.zig
    2. 1/1 test "this will fail"...reached unreachable code
    3. /deps/zig/docgen_tmp/test.zig:2:14: 0x2052cb in assert (test)
    4. if (!ok) unreachable; // assertion failure
    5. ^
    6. /deps/zig/docgen_tmp/test.zig:7:11: 0x204b8e in test "this will fail" (test)
    7. ^
    8. /deps/zig/lib/std/special/test_runner.zig:47:28: 0x22bade in std.special.main (test)
    9. } else test_fn.func();
    10. ^
    11. /deps/zig/lib/std/start.zig:253:37: 0x20560d in std.start.posixCallMainAndExit (test)
    12. const result = root.main() catch |err| {
    13. /deps/zig/lib/std/start.zig:123:5: 0x20534f in std.start._start (test)
    14. @call(.{ .modifier = .never_inline }, posixCallMainAndExit, .{});
    15. ^
    16. /deps/zig/docgen_tmp/test

    At Compile-Time

    test.zig

    1. $ zig test test.zig
    2. ./docgen_tmp/test.zig:10:16: error: unreachable code
    3. assert(@TypeOf(unreachable) == noreturn);
    4. ^
    5. ./docgen_tmp/test.zig:3:28: note: referenced here
    6. test "type of unreachable" {
    7. ^