| author | |
| committer | |
| log | 583afd6f0c01336c20dcd218cb7d14aad6894ab1 |
| tree | 5b39030b656063959df4c7841ffd8be93cc44115 |
| parent | f64f3423e4a4d63838a54dfb01f5cd9ea8f68b19 |
| signature |
2 files changed, 20 insertions(+), 2 deletions(-)
src/value.zig+2-2| ... | ... | @@ -597,10 +597,10 @@ pub const Value = struct { |
| 597 | 597 | var check = val; |
| 598 | 598 | while (true) switch (mod.intern_pool.indexToKey(check.toIntern())) { |
| 599 | 599 | .ptr => |ptr| switch (ptr.addr) { |
| 600 | .decl, .mut_decl, .comptime_field => return true, | |
| 600 | .decl, .mut_decl, .comptime_field, .anon_decl => return true, | |
| 601 | 601 | .eu_payload, .opt_payload => |base| check = base.toValue(), |
| 602 | 602 | .elem, .field => |base_index| check = base_index.base.toValue(), |
| 603 | else => return false, | |
| 603 | .int => return false, | |
| 604 | 604 | }, |
| 605 | 605 | else => return false, |
| 606 | 606 | }; |
test/cases/compile_errors/unable_to_evaluate_comptime_expr.zig+18| ... | ... | @@ -16,6 +16,22 @@ pub export fn entry2() void { |
| 16 | 16 | _ = b; |
| 17 | 17 | } |
| 18 | 18 | |
| 19 | const Int = @typeInfo(bar).Struct.backing_integer.?; | |
| 20 | ||
| 21 | const foo = enum(Int) { | |
| 22 | c = @bitCast(bar{ | |
| 23 | .name = "test", | |
| 24 | }), | |
| 25 | }; | |
| 26 | ||
| 27 | const bar = packed struct { | |
| 28 | name: [*:0]const u8, | |
| 29 | }; | |
| 30 | ||
| 31 | pub export fn entry3() void { | |
| 32 | _ = @field(foo, "c"); | |
| 33 | } | |
| 34 | ||
| 19 | 35 | // error |
| 20 | 36 | // backend=stage2 |
| 21 | 37 | // target=native |
| ... | ... | @@ -24,3 +40,5 @@ pub export fn entry2() void { |
| 24 | 40 | // :7:16: note: operation is runtime due to this operand |
| 25 | 41 | // :13:13: error: unable to evaluate comptime expression |
| 26 | 42 | // :13:16: note: operation is runtime due to this operand |
| 43 | // :22:9: error: unable to evaluate comptime expression | |
| 44 | // :22:21: note: operation is runtime due to this operand |