From f0f58dacb350c70c7617210072896bab2c16bdec Mon Sep 17 00:00:00 2001 From: Asger F Date: Fri, 27 Feb 2026 11:44:31 +0100 Subject: [PATCH] JS: Also emit 'this' variable for class scopes --- .../src/com/semmle/js/extractor/ASTExtractor.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/javascript/extractor/src/com/semmle/js/extractor/ASTExtractor.java b/javascript/extractor/src/com/semmle/js/extractor/ASTExtractor.java index caf5d834f90..7eee8b628f7 100644 --- a/javascript/extractor/src/com/semmle/js/extractor/ASTExtractor.java +++ b/javascript/extractor/src/com/semmle/js/extractor/ASTExtractor.java @@ -1545,8 +1545,9 @@ public class ASTExtractor { if (!isClassExpression) { visit(ac.getId(), key, 0, IdContext.VAR_AND_TYPE_DECL); } + scopeManager.enterScope(scopeNode); + scopeManager.addVariables("this"); // 'this' in static field initialiers refers to the class if (ac.hasId() || ac.hasTypeParameters()) { - scopeManager.enterScope(scopeNode); if (isClassExpression && ac.hasId()) { scopeManager.addVariables(ac.getId().getName()); scopeManager.addTypeName(ac.getId().getName()); @@ -1569,9 +1570,7 @@ public class ASTExtractor { addDefaultConstructor(ac); } visit(ac.getBody(), key, 2); - if (ac.hasId() || ac.hasTypeParameters()) { - scopeManager.leaveScope(); - } + scopeManager.leaveScope(); emitNodeSymbol(ac, key); return key; }