diff options
| author | Veikka Tuominen <git@vexu.eu> | 2022-11-26 18:04:07 +0200 |
|---|---|---|
| committer | Veikka Tuominen <git@vexu.eu> | 2022-11-26 18:05:27 +0200 |
| commit | 71937f75d83d960e0ec61eb697e4e3420685f9ca (patch) | |
| tree | 41b7b3eb8c30a6f2531d0e889b593f802f5982a2 /src/Sema.zig | |
| parent | fe388982462db067bdb697ec3e89c2c13ce2ffa8 (diff) | |
| download | zig-71937f75d83d960e0ec61eb697e4e3420685f9ca.tar.gz zig-71937f75d83d960e0ec61eb697e4e3420685f9ca.zip | |
Sema: correctly detect union target in `zirSwitchBlock`
Closes #13655
Diffstat (limited to 'src/Sema.zig')
| -rw-r--r-- | src/Sema.zig | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/Sema.zig b/src/Sema.zig index f056164f80..3476024222 100644 --- a/src/Sema.zig +++ b/src/Sema.zig @@ -9698,10 +9698,12 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError }; const maybe_union_ty = blk: { + const zir_tags = sema.code.instructions.items(.tag); const zir_data = sema.code.instructions.items(.data); const cond_index = Zir.refToIndex(extra.data.operand).?; const raw_operand = sema.resolveInst(zir_data[cond_index].un_node.operand) catch unreachable; - break :blk sema.typeOf(raw_operand); + const target_ty = sema.typeOf(raw_operand); + break :blk if (zir_tags[cond_index] == .switch_cond_ref) target_ty.elemType() else target_ty; }; const union_originally = maybe_union_ty.zigTypeTag() == .Union; |
