From 0d6b491fd4c946ef5cd8344b624ac8e9c90161f8 Mon Sep 17 00:00:00 2001 From: lisyarus Date: Sun, 15 Mar 2026 16:34:14 +0300 Subject: [PATCH] Fix resolving top scope variables in resolve_identifiers (were considered global, but not anymore) --- libs/ast/source/resolve_identifiers.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/libs/ast/source/resolve_identifiers.cpp b/libs/ast/source/resolve_identifiers.cpp index 612de15..42fe176 100644 --- a/libs/ast/source/resolve_identifiers.cpp +++ b/libs/ast/source/resolve_identifiers.cpp @@ -53,7 +53,6 @@ namespace pslang::ast } bool is_function_scope = false; - bool is_global_scope = false; }; struct populate_globals_visitor @@ -172,7 +171,7 @@ namespace pslang::ast bool crossed_function_scope = false; for (auto it = scopes.rbegin(); it != scopes.rend(); ++it) { - if (it->contains(identifier.name, crossed_function_scope && !it->is_global_scope)) + if (it->contains(identifier.name, crossed_function_scope)) { identifier.level = it.base() - scopes.begin() - 1; return; @@ -382,7 +381,7 @@ namespace pslang::ast void resolve_identifiers(statement_list_ptr & statements) { std::vector scopes; - scopes.emplace_back().is_global_scope = true; + scopes.emplace_back(); resolve_identifiers_visitor visitor{{}, {}, {}, scopes}; visitor.apply(*statements); }