refine returned match errors

This commit is contained in:
2026-07-22 02:04:48 +02:00
parent 2c2a310e6d
commit 8e153fa84e
9 changed files with 586 additions and 16 deletions
+11 -1
View File
@@ -497,6 +497,15 @@ lower_compound_expr :: proc(state: ^State, expr_id: hir.Expr_Id) -> ir.Instructi
target=ir.INVALID_REF, a=ir.INVALID_INSTRUCTION, b=ir.INVALID_INSTRUCTION,
diagnostic=source.INVALID_DIAGNOSTIC,
})
} else if expr.right == hir.INVALID_EXPR {
// A terminating handler can still end in a synthetic match/if merge label
// after its returns. Seal that unreachable continuation before the success
// label so LLVM never sees adjacent basic-block labels.
append_instruction(state, ir.Instruction{
op=.Trap, span=expr.span, type=types.NORETURN, integer=1,
target=ir.INVALID_REF, a=ir.INVALID_INSTRUCTION, b=ir.INVALID_INSTRUCTION,
diagnostic=source.INVALID_DIAGNOSTIC,
})
}
}
if expr.right != hir.INVALID_EXPR {
@@ -768,7 +777,7 @@ lower_expr :: proc(state: ^State, expr_id: hir.Expr_Id) -> ir.Instruction_Id {
})
}
_ = pop(&stack)
case .Widen, .Sum_Widen, .C_Coerce, .C_Vararg_Promote, .Retype, .Scalar_Cast, .Pointer_Cast, .Const_Cast, .Weaken_Pointer, .Weaken_Slice, .Decay_Array_Pointer:
case .Widen, .Sum_Widen, .Sum_Project, .C_Coerce, .C_Vararg_Promote, .Retype, .Scalar_Cast, .Pointer_Cast, .Const_Cast, .Weaken_Pointer, .Weaken_Slice, .Decay_Array_Pointer:
stack[frame_index].stage = 1
append(&stack, Lower_Expr_Frame{expr=expr.left})
case .Negate, .Bit_Not:
@@ -829,6 +838,7 @@ lower_expr :: proc(state: ^State, expr_id: hir.Expr_Id) -> ir.Instruction_Id {
op := ir.Opcode.Widen
#partial switch expr.kind {
case .Sum_Widen: op = .Sum_Widen
case .Sum_Project: op = .Sum_Project
case .Weaken_Pointer: op = .Weaken_Pointer
case .Weaken_Slice: op = .Weaken_Slice
case .Decay_Array_Pointer: op = .Decay_Array_Pointer