| ... | @@ -11658,7 +11658,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r | ... | @@ -11658,7 +11658,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index, operand_is_r |
| 11658 | | 11658 | |
| 11659 | // Validate for duplicate items, missing else prong, and invalid range. | 11659 | // Validate for duplicate items, missing else prong, and invalid range. |
| 11660 | switch (operand_ty.zigTypeTag(mod)) { | 11660 | switch (operand_ty.zigTypeTag(mod)) { |
| 11661 | .Union => unreachable, // handled in zirSwitchCond | 11661 | .Union => unreachable, // handled in `switchCond` |
| 11662 | .Enum => { | 11662 | .Enum => { |
| 11663 | seen_enum_fields = try gpa.alloc(?Module.SwitchProngSrc, operand_ty.enumFieldCount(mod)); | 11663 | seen_enum_fields = try gpa.alloc(?Module.SwitchProngSrc, operand_ty.enumFieldCount(mod)); |
| 11664 | empty_enum = seen_enum_fields.len == 0 and !operand_ty.isNonexhaustiveEnum(mod); | 11664 | empty_enum = seen_enum_fields.len == 0 and !operand_ty.isNonexhaustiveEnum(mod); |
| ... | @@ -33747,7 +33747,10 @@ fn unionToTag( | ... | @@ -33747,7 +33747,10 @@ fn unionToTag( |
| 33747 | return Air.internedToRef(opv.toIntern()); | 33747 | return Air.internedToRef(opv.toIntern()); |
| 33748 | } | 33748 | } |
| 33749 | if (try sema.resolveValue(un)) |un_val| { | 33749 | if (try sema.resolveValue(un)) |un_val| { |
| 33750 | return Air.internedToRef(un_val.unionTag(mod).?.toIntern()); | 33750 | const tag_val = un_val.unionTag(mod).?; |
| | 33751 | if (tag_val.isUndef(mod)) |
| | 33752 | return try mod.undefRef(enum_ty); |
| | 33753 | return Air.internedToRef(tag_val.toIntern()); |
| 33751 | } | 33754 | } |
| 33752 | try sema.requireRuntimeBlock(block, un_src, null); | 33755 | try sema.requireRuntimeBlock(block, un_src, null); |
| 33753 | return block.addTyOp(.get_union_tag, enum_ty, un); | 33756 | return block.addTyOp(.get_union_tag, enum_ty, un); |