From 1f5a49151fc2f72932eedf8162b63af670556910 Mon Sep 17 00:00:00 2001 From: Mel Date: Tue, 23 Aug 2022 00:03:22 +0000 Subject: Only transform symbols into envs if they were vars --- pkg/lang/compiler/scope/scope_chain.go | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'pkg') diff --git a/pkg/lang/compiler/scope/scope_chain.go b/pkg/lang/compiler/scope/scope_chain.go index ba4c4c2..3d69e64 100644 --- a/pkg/lang/compiler/scope/scope_chain.go +++ b/pkg/lang/compiler/scope/scope_chain.go @@ -260,15 +260,17 @@ func (sc *ScopeChain) Lookup(name string) (SymbolID, bool) { } } - // Check whether the symbol is outside the current function scope. - fnScope := sc.CurrentFunction() - if id.scopeID < fnScope.id { - // Return env symbol instead of a local symbol. - return SymbolID{ - symbolKind: SymbolKindEnv, - scopeID: id.scopeID, - indexInScope: id.indexInScope, - }, true + if id.symbolKind == SymbolKindVariable { + // Check whether the variable symbol is outside the current function scope. + fnScope := sc.CurrentFunction() + if id.scopeID < fnScope.id { + // Return env symbol instead of a local symbol. + return SymbolID{ + symbolKind: SymbolKindEnv, + scopeID: id.scopeID, + indexInScope: id.indexInScope, + }, true + } } return id, true -- cgit 1.4.1