Fix resolving top scope variables in resolve_identifiers (were considered global, but not anymore)

This commit is contained in:
Nikita Lisitsa 2026-03-15 16:34:14 +03:00
parent bcdcc9e752
commit 0d6b491fd4

View file

@ -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<scope> scopes;
scopes.emplace_back().is_global_scope = true;
scopes.emplace_back();
resolve_identifiers_visitor visitor{{}, {}, {}, scopes};
visitor.apply(*statements);
}