aboutsummaryrefslogtreecommitdiff
path: root/test/cases/compile_errors/self_referential_union_requires_comptime.zig
blob: a2433adde9786a283b5deada7f3493d41fb1f688 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
const U = union {
    a: fn () void,
    b: *U,
};
pub export fn entry() void {
    var u: U = undefined;
    _ = u;
}

// error
// backend=stage2
// target=native
//
// :6:12: error: variable of type 'tmp.U' must be const or comptime
// :2:8: note: union requires comptime because of this field
// :2:8: note: use '*const fn() void' for a function pointer type
// :3:8: note: union requires comptime because of this field