Be somewhat less conservative about declaring things global.

This commit is contained in:
Adam Kelly 2019-08-31 18:15:56 +01:00
parent 9c17d982ff
commit f3ecba02b1

View file

@ -251,9 +251,12 @@ impl SymbolTableAnalyzer {
if found_in_outer_scope {
// Symbol is in some outer scope.
symbol.is_free = true;
} else {
} else if self.tables.is_empty() {
// Don't make assumptions when we don't know.
symbol.scope = SymbolScope::Unknown;
} else {
// If there are scopes above we can assume global.
symbol.scope = SymbolScope::Global;
}
}
}