From ea902858825aac806cd282e6d5f02ec683a995e3 Mon Sep 17 00:00:00 2001 From: Eugen Wissner Date: Thu, 8 Oct 2026 20:18:48 +0200 Subject: Fix ICE with local block variables --- boot/type_check.cc | 10 ++++++++++ include/elna/boot/type_check.h | 2 ++ testsuite/compilable/block_variables.elna | 8 ++++++++ 3 files changed, 20 insertions(+) create mode 100644 testsuite/compilable/block_variables.elna diff --git a/boot/type_check.cc b/boot/type_check.cc index d8a9170..31e10f1 100644 --- a/boot/type_check.cc +++ b/boot/type_check.cc @@ -1506,6 +1506,16 @@ namespace elna::boot } // else callable is not declared, or inference failed and reported. } + + void type_analysis_visitor::visit(defer_statement *statement) + { + traverse_block(statement->body); + } + + void type_analysis_visitor::visit(block_statement *statement) + { + traverse_block(statement->body); + } void type_analysis_visitor::visit(record_constructor_expression *expression) { diff --git a/include/elna/boot/type_check.h b/include/elna/boot/type_check.h index 5a2d7f1..d9a07b9 100644 --- a/include/elna/boot/type_check.h +++ b/include/elna/boot/type_check.h @@ -317,6 +317,8 @@ namespace elna::boot void visit(repeat_statement *statement) override; void visit(while_statement *statement) override; void visit(if_statement *statement) override; + void visit(defer_statement *statement) override; + void visit(block_statement *statement) override; void visit(record_constructor_expression *expression) override; void visit(array_constructor_expression *expression) override; void visit(traits_expression *trait) override; diff --git a/testsuite/compilable/block_variables.elna b/testsuite/compilable/block_variables.elna new file mode 100644 index 0000000..c67e8b6 --- /dev/null +++ b/testsuite/compilable/block_variables.elna @@ -0,0 +1,8 @@ +program() + +begin + block b + var + x: Int + end +end. -- cgit v1.2.3