mirror of
https://github.com/ziglang/zig.git
synced 2026-01-04 04:25:05 +00:00
value: update isDeclRef for anonymous declarations
This commit is contained in:
parent
f64f3423e4
commit
583afd6f0c
@ -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,
|
||||
};
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user