authorgravatar for wrongnull@gmail.comBogdan Romanyuk <wrongnull@gmail.com> 2023-11-21 14:21:32+03:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2023-11-21 13:21:32+02:00
log583afd6f0c01336c20dcd218cb7d14aad6894ab1
tree5b39030b656063959df4c7841ffd8be93cc44115
parentf64f3423e4a4d63838a54dfb01f5cd9ea8f68b19
signaturebadge-question-mark Signed by PGP key 4AEE18F83AFDEB23

value: update isDeclRef for anonymous declarations


2 files changed, 20 insertions(+), 2 deletions(-)

src/value.zig+2-2
......@@ -597,10 +597,10 @@ pub const Value = struct {
597597 var check = val;
598598 while (true) switch (mod.intern_pool.indexToKey(check.toIntern())) {
599599 .ptr => |ptr| switch (ptr.addr) {
600 .decl, .mut_decl, .comptime_field => return true,
600 .decl, .mut_decl, .comptime_field, .anon_decl => return true,
601601 .eu_payload, .opt_payload => |base| check = base.toValue(),
602602 .elem, .field => |base_index| check = base_index.base.toValue(),
603 else => return false,
603 .int => return false,
604604 },
605605 else => return false,
606606 };
test/cases/compile_errors/unable_to_evaluate_comptime_expr.zig+18
......@@ -16,6 +16,22 @@ pub export fn entry2() void {
1616 _ = b;
1717}
1818
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
1935// error
2036// backend=stage2
2137// target=native
......@@ -24,3 +40,5 @@ pub export fn entry2() void {
2440// :7:16: note: operation is runtime due to this operand
2541// :13:13: error: unable to evaluate comptime expression
2642// :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