undefined assignment

This commit is contained in:
2026-06-25 20:37:20 +02:00
parent e0b6f6049c
commit ca6cc89da0
10 changed files with 489 additions and 47 deletions
+13 -1
View File
@@ -613,7 +613,6 @@ lower_statements :: proc(state: ^State, statements: []hir.Stmt_Id) {
statement := hir_module.statements[statement_id]
switch statement.kind {
case .Declaration:
value := lower_expr(state, statement.expr)
if statement.local == hir.INVALID_LOCAL || int(statement.local) >= len(state.func_locals) {
append_instruction(state, ir.Instruction{
op=.Trap, span=statement.span, type=types.VOID,
@@ -632,6 +631,19 @@ lower_statements :: proc(state: ^State, statements: []hir.Stmt_Id) {
diagnostic=source.INVALID_DIAGNOSTIC,
})
state.local_slots[statement.local] = slot
if statement.expr == hir.INVALID_EXPR {
append_instruction(state, ir.Instruction{
op=.Fill,
span=statement.span,
type=local.type,
target=ir.INVALID_REF,
a=slot,
b=ir.INVALID_INSTRUCTION,
diagnostic=source.INVALID_DIAGNOSTIC,
})
continue
}
value := lower_expr(state, statement.expr)
append_instruction(state, ir.Instruction{
op=.Store,
span=statement.span,