#zig build-obj {
--name test -fno-emit-bin
-Mroot=test.zig
#}

#write test.zig {
var rt_val: [5]u32 = .{ 1, 2, 3, 4, 5 };

comptime {
    _ = rt_val; // fine
}

comptime {
    const a = rt_val; // error
    _ = a;
}

comptime {
    const l = rt_val.len; // fine
    @compileLog(l);
}

export fn foo() void {
    _ = comptime rt_val; // error
}

export fn bar() void {
    const l = comptime rt_val.len; // fine
    @compileLog(l);
}

export fn baz() void {
    const S = struct {
        fn inner() void {
            _ = comptime rt_val;
        }
    };
    comptime S.inner(); // fine; inner comptime is a nop
    S.inner(); // error
}

export fn qux() void {
    const S = struct {
        fn inner() void {
            const a = rt_val;
            _ = a;
        }
    };
    S.inner(); // fine; everything is runtime
    comptime S.inner(); // error
}
#}
#update
#check errors {
test.zig:8:15: error: unable to resolve comptime value
test.zig:7:1: note: 'comptime' keyword forces comptime evaluation
test.zig:18:9: error: unable to resolve comptime value
test.zig:18:9: note: 'comptime' keyword forces comptime evaluation
test.zig:29:17: error: unable to resolve comptime value
test.zig:29:17: note: 'comptime' keyword forces comptime evaluation
test.zig:39:23: error: unable to resolve comptime value
test.zig:44:21: note: called at comptime from here
test.zig:44:5: note: 'comptime' keyword forces comptime evaluation

Compile Log Output:
@as(usize, 5)
@as(usize, 5)
#}
