From b52948444f16c082f0e29bb75b246370c4b11326 Mon Sep 17 00:00:00 2001 From: Cody Tapscott Date: Sun, 27 Feb 2022 01:53:56 -0700 Subject: [PATCH] stage2: Resolve union layout before getting tag type in zirTagname This bug only causes a failure on my machine when running test/behavior/eval.zig directly. If running the full behavior test suite, std.builtin.TypeInfo will have already resolved its layout, causing the test to pass. I'd love to add a test that can reliably reproduce this problem, but I'm afraid I'm not sure how to reliably create a union with un-resolved layout. --- src/Sema.zig | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Sema.zig b/src/Sema.zig index 8e93d2525b..4dad9a6c8c 100644 --- a/src/Sema.zig +++ b/src/Sema.zig @@ -11837,6 +11837,7 @@ fn zirTagName(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air const operand = sema.resolveInst(inst_data.operand); const operand_ty = sema.typeOf(operand); + try sema.resolveTypeLayout(block, operand_src, operand_ty); const enum_ty = switch (operand_ty.zigTypeTag()) { .EnumLiteral => { const val = try sema.resolveConstValue(block, operand_src, operand);