JS: Enhance void context propagation

This commit is contained in:
Napalys Klicius
2025-06-03 15:20:55 +02:00
parent bf48b59874
commit 46b5ded862
4 changed files with 7 additions and 2 deletions

View File

@@ -22,6 +22,9 @@ predicate inVoidContext(Expr e) {
)
)
or
// propagate void context through parenthesized expressions
inVoidContext(e.getParent().(ParExpr))
or
exists(SeqExpr seq, int i, int n |
e = seq.getOperand(i) and
n = seq.getNumOperands()

View File

@@ -11,4 +11,6 @@
| tst.js:49:3:49:49 | new Syn ... o me?") | This expression has no effect. |
| tst.js:50:3:50:36 | new Err ... age(e)) | This expression has no effect. |
| tst.js:61:2:61:20 | o.trivialNonGetter1 | This expression has no effect. |
| tst.js:75:3:75:3 | o | This expression has no effect. |
| tst.js:77:24:77:24 | o | This expression has no effect. |
| uselessfn.js:1:2:1:26 | functio ... d.");\\n} | This expression has no effect. |

View File

@@ -72,7 +72,7 @@ function g() {
Object.defineProperty(o, "nonTrivialGetter2", unknownGetterDef());
o.nonTrivialGetter2;
(o: empty);
(o: empty); // $SPURIOUS:Alert
testSomeCondition() ? o : // $ Alert
doSomethingDangerous();

View File

@@ -1,3 +1,3 @@
(function f() { // $MISSING: Alert
(function f() { // $ Alert
console.log("I'm never called.");
})