From 7440060f179e35fe63155a149bb5003c97e12013 Mon Sep 17 00:00:00 2001 From: Eugen Wissner Date: Sun, 18 Oct 2026 09:25:36 +0200 Subject: Fix ICE on variable declarations in case branches --- boot/ast.cc | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) (limited to 'boot/ast.cc') diff --git a/boot/ast.cc b/boot/ast.cc index 15e4928..e712f16 100644 --- a/boot/ast.cc +++ b/boot/ast.cc @@ -243,7 +243,7 @@ namespace elna::boot } if (declaration->body.has_value()) { - traverse_block(this, declaration->body.value()); + boot::traverse_block(this, declaration->body.value()); if (declaration->body.value().return_expression != nullptr) { declaration->body.value().return_expression->accept(this); @@ -257,54 +257,59 @@ namespace elna::boot statement->rvalue().accept(this); } + void walking_visitor::traverse_block(const block& body) + { + boot::traverse_block(this, body); + } + void walking_visitor::visit(if_statement *statement) { statement->branch().prerequisite().accept(this); - traverse_block(this, statement->branch().body); + traverse_block(statement->branch().body); for (conditional_statements& branch : statement->branches) { branch.prerequisite().accept(this); - traverse_block(this, branch.body); + traverse_block(branch.body); } if (statement->alternative != nullptr) { - traverse_block(this, *statement->alternative); + traverse_block(*statement->alternative); } } void walking_visitor::visit(while_statement *statement) { statement->branch().prerequisite().accept(this); - traverse_block(this, statement->branch().body); + traverse_block(statement->branch().body); for (conditional_statements& branch : statement->branches) { branch.prerequisite().accept(this); - traverse_block(this, branch.body); + traverse_block(branch.body); } } void walking_visitor::visit(repeat_statement *statement) { statement->condition().accept(this); - traverse_block(this, statement->body); + traverse_block(statement->body); } void walking_visitor::visit(for_statement *statement) { statement->range().accept(this); - traverse_block(this, statement->body); + traverse_block(statement->body); } void walking_visitor::visit(defer_statement *statement) { - traverse_block(this, statement->body); + traverse_block(statement->body); } void walking_visitor::visit(block_statement *statement) { - traverse_block(this, statement->body); + traverse_block(statement->body); } void walking_visitor::visit(break_statement *) @@ -321,11 +326,11 @@ namespace elna::boot for (const switch_case& case_block : statement->cases) { visit_all(this, case_block.labels); - traverse_block(this, case_block.body); + traverse_block(case_block.body); } if (statement->alternative != nullptr) { - traverse_block(this, *statement->alternative); + traverse_block(*statement->alternative); } } -- cgit v1.2.3