Skip to content

Commit e0ab5ce

Browse files
committed
JS: Emit variables for 'this'
The extractor does not emit bindings for 'this', we just ensure that a variable exists for it
1 parent f0e665d commit e0ab5ce

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

javascript/extractor/src/com/semmle/js/extractor/ASTExtractor.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -819,6 +819,7 @@ public Label visit(Program nd, Context c) {
819819
// add all declared global (or module-scoped) names, both non-lexical and lexical
820820
scopeManager.addNames(scopeManager.collectDeclaredNames(nd, isStrict, false, DeclKind.none));
821821
scopeManager.addNames(scopeManager.collectDeclaredNames(nd, isStrict, true, DeclKind.none));
822+
scopeManager.addVariables("this");
822823

823824
visitAll(nd.getBody(), toplevelLabel);
824825

@@ -1070,6 +1071,9 @@ private void extractFunction(IFunction nd, Label key) {
10701071

10711072
scopeManager.enterScope((Node) nd);
10721073
scopeManager.addNames(locals);
1074+
if (!(nd instanceof ArrowFunctionExpression)) {
1075+
scopeManager.addVariables("this");
1076+
}
10731077

10741078
// The name of a function expression binds to its own scope.
10751079
if (nd.getId() != null && nd instanceof AFunctionExpression) {

0 commit comments

Comments
 (0)