about summary refs log tree commit diff
path: root/pkg/lang/compiler/scope/scope_chain.go
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/lang/compiler/scope/scope_chain.go')
-rw-r--r--pkg/lang/compiler/scope/scope_chain.go20
1 files changed, 11 insertions, 9 deletions
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