aboutsummaryrefslogtreecommitdiff
path: root/test/cases/compile_errors/runtime_operation_in_comptime_scope.zig
blob: 8c1d31adf299188a4da513b38898f290b3279e63 (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
30
31
32
33
34
35
36
export fn entry1() void {
    foo();
}

comptime {
    qux();
}

inline fn foo() void {
    _ = bar();
}

fn bar() type {
    qux();
    return u8;
}

fn qux() void {
    rt = 123;
}

var rt: u32 = undefined;

// error
//
// :19:8: error: unable to evaluate comptime expression
// :19:5: note: operation is runtime due to this operand
// :14:8: note: called at comptime from here
// :10:12: note: called at comptime from here
// :13:10: note: function with comptime-only return type 'type' is evaluated at comptime
// :13:10: note: types are not available at runtime
// :2:8: note: called from here
// :19:8: error: unable to evaluate comptime expression
// :19:5: note: operation is runtime due to this operand
// :6:8: note: called at comptime from here
// :5:1: note: 'comptime' keyword forces comptime evaluation