From d7e3e9e5db90ad45967a1cc209e241d00168da97 Mon Sep 17 00:00:00 2001 From: Asger F Date: Fri, 20 May 2022 22:04:11 +0200 Subject: [PATCH] JS: Fix extraction of identifiers in EXPORT_BASE context This is needed to ensure that the base of the RHS of an ImportEqualsDeclaration is bound to a namespace. That is, B below should be bound to a namespace: import A = B.C.D; --- .../extractor/src/com/semmle/js/extractor/ASTExtractor.java | 2 +- .../RegressionTests/ExportBaseResolution/test.expected | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/javascript/extractor/src/com/semmle/js/extractor/ASTExtractor.java b/javascript/extractor/src/com/semmle/js/extractor/ASTExtractor.java index e1c059a9088..34e6dda3c64 100644 --- a/javascript/extractor/src/com/semmle/js/extractor/ASTExtractor.java +++ b/javascript/extractor/src/com/semmle/js/extractor/ASTExtractor.java @@ -747,7 +747,7 @@ public class ASTExtractor { visit(nd.getProperty(), key, 1, IdContext.TYPE_LABEL); } else { IdContext baseIdContext = - c.idcontext == IdContext.EXPORT ? IdContext.EXPORT_BASE : IdContext.VAR_BIND; + (c.idcontext == IdContext.EXPORT || c.idcontext == IdContext.EXPORT_BASE) ? IdContext.EXPORT_BASE : IdContext.VAR_BIND; visit(nd.getObject(), key, 0, baseIdContext); visit(nd.getProperty(), key, 1, nd.isComputed() ? IdContext.VAR_BIND : IdContext.LABEL); } diff --git a/javascript/ql/test/library-tests/TypeScript/RegressionTests/ExportBaseResolution/test.expected b/javascript/ql/test/library-tests/TypeScript/RegressionTests/ExportBaseResolution/test.expected index 3825d9e676a..9104b6e76c3 100644 --- a/javascript/ql/test/library-tests/TypeScript/RegressionTests/ExportBaseResolution/test.expected +++ b/javascript/ql/test/library-tests/TypeScript/RegressionTests/ExportBaseResolution/test.expected @@ -1 +1,2 @@ +| A | namespace | test.d.ts:1:19:1:19 | A | test.d.ts:10:14:10:14 | A | | A | variable | test.d.ts:1:19:1:19 | A | test.d.ts:10:14:10:14 | A |