From f3ecba02b121e1e9df089a19335080fd67893f38 Mon Sep 17 00:00:00 2001 From: Adam Kelly Date: Sat, 31 Aug 2019 18:15:56 +0100 Subject: [PATCH] Be somewhat less conservative about declaring things global. --- src/symboltable.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/symboltable.rs b/src/symboltable.rs index ab931ac..c07b5ae 100644 --- a/src/symboltable.rs +++ b/src/symboltable.rs @@ -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; } } }