value: update isDeclRef for anonymous declarations

This commit is contained in:
Bogdan Romanyuk 2023-11-21 14:21:32 +03:00 committed by GitHub
parent f64f3423e4
commit 583afd6f0c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 2 deletions

View File

@ -597,10 +597,10 @@ pub const Value = struct {
var check = val;
while (true) switch (mod.intern_pool.indexToKey(check.toIntern())) {
.ptr => |ptr| switch (ptr.addr) {
.decl, .mut_decl, .comptime_field => return true,
.decl, .mut_decl, .comptime_field, .anon_decl => return true,
.eu_payload, .opt_payload => |base| check = base.toValue(),
.elem, .field => |base_index| check = base_index.base.toValue(),
else => return false,
.int => return false,
},
else => return false,
};

View File

@ -16,6 +16,22 @@ pub export fn entry2() void {
_ = b;
}
const Int = @typeInfo(bar).Struct.backing_integer.?;
const foo = enum(Int) {
c = @bitCast(bar{
.name = "test",
}),
};
const bar = packed struct {
name: [*:0]const u8,
};
pub export fn entry3() void {
_ = @field(foo, "c");
}
// error
// backend=stage2
// target=native
@ -24,3 +40,5 @@ pub export fn entry2() void {
// :7:16: note: operation is runtime due to this operand
// :13:13: error: unable to evaluate comptime expression
// :13:16: note: operation is runtime due to this operand
// :22:9: error: unable to evaluate comptime expression
// :22:21: note: operation is runtime due to this operand