Commit 583afd6f0c
Changed files (2)
src
test
cases
compile_errors
src/value.zig
@@ -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,
};
test/cases/compile_errors/unable_to_evaluate_comptime_expr.zig
@@ -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