Skip to content

Commit 527f3ff

Browse files
committed
Be somewhat less conservative about declaring things global.
1 parent b087325 commit 527f3ff

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

compiler/src/symboltable.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,9 +251,12 @@ impl SymbolTableAnalyzer {
251251
if found_in_outer_scope {
252252
// Symbol is in some outer scope.
253253
symbol.is_free = true;
254-
} else {
254+
} else if self.tables.is_empty() {
255255
// Don't make assumptions when we don't know.
256256
symbol.scope = SymbolScope::Unknown;
257+
} else {
258+
// If there are scopes above we can assume global.
259+
symbol.scope = SymbolScope::Global;
257260
}
258261
}
259262
}

0 commit comments

Comments
 (0)