From f788955b59de03ca7b17a3049f30b3260f2e6803 Mon Sep 17 00:00:00 2001 From: Asger F Date: Mon, 11 Nov 2024 16:35:41 +0100 Subject: [PATCH] JS: Handle sequence expressions in visitExpression --- .../src/com/semmle/js/extractor/AbstractDetector.java | 6 ++++++ javascript/ql/test/library-tests/ModuleTypes/tests.expected | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/javascript/extractor/src/com/semmle/js/extractor/AbstractDetector.java b/javascript/extractor/src/com/semmle/js/extractor/AbstractDetector.java index 770666ce0ef1..4f0717443a11 100644 --- a/javascript/extractor/src/com/semmle/js/extractor/AbstractDetector.java +++ b/javascript/extractor/src/com/semmle/js/extractor/AbstractDetector.java @@ -12,6 +12,7 @@ import com.semmle.js.ast.Node; import com.semmle.js.ast.ParenthesizedExpression; import com.semmle.js.ast.Program; +import com.semmle.js.ast.SequenceExpression; import com.semmle.js.ast.Statement; import com.semmle.js.ast.TryStatement; import com.semmle.js.ast.UnaryExpression; @@ -88,6 +89,11 @@ protected boolean visitExpression(Expression e) { if (body instanceof BlockStatement) { return visitStatement((BlockStatement) body); } + } else if (e instanceof SequenceExpression) { + SequenceExpression seq = (SequenceExpression) e; + for (Expression child : seq.getExpressions()) { + if (visitExpression(child)) return true; + } } return false; } diff --git a/javascript/ql/test/library-tests/ModuleTypes/tests.expected b/javascript/ql/test/library-tests/ModuleTypes/tests.expected index 15332636c8fd..103a65951db0 100644 --- a/javascript/ql/test/library-tests/ModuleTypes/tests.expected +++ b/javascript/ql/test/library-tests/ModuleTypes/tests.expected @@ -8,4 +8,4 @@ | modulePackage/tst.js:1:1:1:75 | | es2015 | | require.js:1:1:7:1 | | node | | script.js:1:1:1:35 | | non-module | -| toplevel-comma.js:1:1:5:0 | | non-module | +| toplevel-comma.js:1:1:5:0 | | node |