From 08d9c4292ebba3e320c1dbaca4fa06c83f6fc7fb Mon Sep 17 00:00:00 2001 From: Eugen Wissner Date: Sat, 29 Aug 2026 10:03:11 +0200 Subject: Fix procedure order resolution --- boot/dependency.cc | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'boot/dependency.cc') diff --git a/boot/dependency.cc b/boot/dependency.cc index 7e103aa..9b52ce9 100644 --- a/boot/dependency.cc +++ b/boot/dependency.cc @@ -68,19 +68,30 @@ namespace elna::boot const std::shared_ptr& globals, const target_info& target, const std::filesystem::path& module_path) { - declaration_visitor declarations{}; - tree->accept(&declarations); - analysis_result result{ .value = { std::move(declarations.unresolved), globals }, .errors = {} }; + forward_declaration_visitor forward_declarer; - if (declarations.has_errors()) + tree->accept(&forward_declarer); + + analysis_result result{ + .value = symbol_bag(std::move(forward_declarer.unresolved), globals), + .errors = std::move(forward_declarer.errors()) + }; + if (!result.errors.empty()) { - std::swap(result.errors, declarations.errors()); return result; } for (const auto& import : imports) { result.value.add_import(import); } + declaration_visitor declarations(result.value, target, module_path); + tree->accept(&declarations); + + if (declarations.has_errors()) + { + std::swap(result.errors, declarations.errors()); + return result; + } name_analysis_visitor name_analyser(result.value, target, module_path); tree->accept(&name_analyser); -- cgit v1.2.3