diff options
| author | Mel <einebeere@gmail.com> | 2022-08-23 00:03:22 +0000 |
|---|---|---|
| committer | Mel <einebeere@gmail.com> | 2022-08-23 00:03:22 +0000 |
| commit | 1f5a49151fc2f72932eedf8162b63af670556910 (patch) | |
| tree | cfd909ab5ae6680ae9ffa3c6cb98ee2cdbe59be6 /pkg | |
| parent | 0b227d990f56b3ea059d13584ff9102ee5039a0b (diff) | |
| download | jinx-1f5a49151fc2f72932eedf8162b63af670556910.tar.zst jinx-1f5a49151fc2f72932eedf8162b63af670556910.zip | |
Only transform symbols into envs if they were vars
Diffstat (limited to 'pkg')
| -rw-r--r-- | pkg/lang/compiler/scope/scope_chain.go | 20 |
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 |
