JS: Reset implicit variable scope when leaving template expr

This commit is contained in:
Asger Feldthaus
2021-07-22 10:51:54 +02:00
parent d658ef1dcd
commit d1c31db06f
2 changed files with 12 additions and 1 deletions

View File

@@ -732,7 +732,10 @@ public class ASTExtractor {
visitAll(nd.getBody(), toplevelLabel);
// Leave the local scope again.
if (sourceType.hasLocalScope()) scopeManager.leaveScope();
if (sourceType.hasLocalScope()) {
scopeManager.leaveScope();
scopeManager.resetImplicitVariableScope();
}
contextManager.leaveContainer();

View File

@@ -119,6 +119,14 @@ public class ScopeManager {
this.implicitVariableScope = implicitVariableScope;
}
/**
* Reset the scope in which to declare variables that are referenced without
* being declared back to the global scope.
*/
public void resetImplicitVariableScope() {
this.implicitVariableScope = toplevelScope;
}
/**
* Enter a new scope.
*