| ... | ... | @@ -9663,6 +9663,9 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError |
| 9663 | 9663 | const extra = sema.code.extraData(Zir.Inst.SwitchBlock, inst_data.payload_index); |
| 9664 | 9664 | |
| 9665 | 9665 | const operand = try sema.resolveInst(extra.data.operand); |
| 9666 | // AstGen guarantees that the instruction immediately following |
| 9667 | // switch_cond(_ref) is a dbg_stmt |
| 9668 | const cond_dbg_node_index = Zir.refToIndex(extra.data.operand).? + 1; |
| 9666 | 9669 | |
| 9667 | 9670 | var header_extra_index: usize = extra.end; |
| 9668 | 9671 | |
| ... | ... | @@ -10359,6 +10362,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError |
| 10359 | 10362 | if (backend_supports_is_named_enum and block.wantSafety() and operand_ty.zigTypeTag() == .Enum and |
| 10360 | 10363 | (!operand_ty.isNonexhaustiveEnum() or union_originally)) |
| 10361 | 10364 | { |
| 10365 | try sema.zirDbgStmt(block, cond_dbg_node_index); |
| 10362 | 10366 | const ok = try block.addUnOp(.is_named_enum_value, operand); |
| 10363 | 10367 | try sema.addSafetyCheck(block, ok, .corrupt_switch); |
| 10364 | 10368 | } |
| ... | ... | @@ -10828,6 +10832,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError |
| 10828 | 10832 | if (backend_supports_is_named_enum and special.body.len != 0 and block.wantSafety() and |
| 10829 | 10833 | operand_ty.zigTypeTag() == .Enum and (!operand_ty.isNonexhaustiveEnum() or union_originally)) |
| 10830 | 10834 | { |
| 10835 | try sema.zirDbgStmt(&case_block, cond_dbg_node_index); |
| 10831 | 10836 | const ok = try case_block.addUnOp(.is_named_enum_value, operand); |
| 10832 | 10837 | try sema.addSafetyCheck(&case_block, ok, .corrupt_switch); |
| 10833 | 10838 | } |
| ... | ... | @@ -10851,6 +10856,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError |
| 10851 | 10856 | // We still need a terminator in this block, but we have proven |
| 10852 | 10857 | // that it is unreachable. |
| 10853 | 10858 | if (case_block.wantSafety()) { |
| 10859 | try sema.zirDbgStmt(&case_block, cond_dbg_node_index); |
| 10854 | 10860 | _ = try sema.safetyPanic(&case_block, src, .corrupt_switch); |
| 10855 | 10861 | } else { |
| 10856 | 10862 | _ = try case_block.addNoOp(.unreach); |
| ... | ... | @@ -23931,7 +23937,7 @@ fn coerceExtra( |
| 23931 | 23937 | inst_ty.isPtrAtRuntime()) |
| 23932 | 23938 | anyopaque_check: { |
| 23933 | 23939 | if (!sema.checkPtrAttributes(dest_ty, inst_ty, &in_memory_result)) break :optional; |
| 23934 | | const elem_ty = inst_ty.elemType2(); |
| 23940 | const elem_ty = inst_ty.elemType2(); |
| 23935 | 23941 | if (elem_ty.zigTypeTag() == .Pointer or elem_ty.isPtrLikeOptional()) { |
| 23936 | 23942 | in_memory_result = .{ .double_ptr_to_anyopaque = .{ |
| 23937 | 23943 | .actual = inst_ty, |
| ... | ... | @@ -23941,7 +23947,7 @@ fn coerceExtra( |
| 23941 | 23947 | } |
| 23942 | 23948 | // Let the logic below handle wrapping the optional now that |
| 23943 | 23949 | // it has been checked to correctly coerce. |
| 23944 | | if (!inst_ty.isPtrLikeOptional()) break: anyopaque_check; |
| 23950 | if (!inst_ty.isPtrLikeOptional()) break :anyopaque_check; |
| 23945 | 23951 | return sema.coerceCompatiblePtrs(block, dest_ty, inst, inst_src); |
| 23946 | 23952 | } |
| 23947 | 23953 | |
| ... | ... | @@ -24066,7 +24072,7 @@ fn coerceExtra( |
| 24066 | 24072 | // but don't do it if the source type is a double pointer |
| 24067 | 24073 | if (dest_info.pointee_type.tag() == .anyopaque and inst_ty.zigTypeTag() == .Pointer) { |
| 24068 | 24074 | if (!sema.checkPtrAttributes(dest_ty, inst_ty, &in_memory_result)) break :pointer; |
| 24069 | | const elem_ty = inst_ty.elemType2(); |
| 24075 | const elem_ty = inst_ty.elemType2(); |
| 24070 | 24076 | if (elem_ty.zigTypeTag() == .Pointer or elem_ty.isPtrLikeOptional()) { |
| 24071 | 24077 | in_memory_result = .{ .double_ptr_to_anyopaque = .{ |
| 24072 | 24078 | .actual = inst_ty, |