master
1var n: u8 = 5;
2
3const S = struct {
4 a: u8,
5};
6
7var a: S = .{ .a = n };
8
9pub export fn entry1() void {
10 _ = a;
11}
12
13var b: S = S{ .a = n };
14
15pub export fn entry2() void {
16 _ = b;
17}
18
19const Int = @typeInfo(bar).@"struct".backing_integer.?;
20
21const foo = enum(Int) {
22 c = @bitCast(bar{
23 .name = "test",
24 }),
25};
26
27const bar = packed struct {
28 name: [*:0]const u8,
29};
30
31pub export fn entry3() void {
32 _ = @field(foo, "c");
33}
34
35// error
36//
37// :7:13: error: unable to evaluate comptime expression
38// :7:16: note: operation is runtime due to this operand
39// :7:13: note: initializer of container-level variable must be comptime-known
40// :13:13: error: unable to evaluate comptime expression
41// :13:16: note: operation is runtime due to this operand
42// :13:13: note: initializer of container-level variable must be comptime-known
43// :22:9: error: unable to evaluate comptime expression
44// :22:21: note: operation is runtime due to this operand
45// :21:13: note: enum field values must be comptime-known