File tree Expand file tree Collapse file tree 4 files changed +33
-6
lines changed
src/semmle/javascript/dataflow
test/query-tests/Statements/UselessConditional Expand file tree Collapse file tree 4 files changed +33
-6
lines changed Original file line number Diff line number Diff line change @@ -1659,7 +1659,7 @@ public Void visit(MemberDefinition<?> nd, SuccessorInfo i) {
16591659
16601660 @ Override
16611661 public Void visit (AssignmentExpression nd , SuccessorInfo i ) {
1662- // `a &&= b` expands to `a || (a = b);`
1662+ // `a &&= b` expands to `a && (a = b);`
16631663 // The CFG is a conditional assignment, so we go through the assignment `nd` last.
16641664 if ("&&=" .equals (nd .getOperator ()) || "||=" .equals (nd .getOperator ()) || "??=" .equals (nd .getOperator ())) {
16651665 if ("&&=" .equals (nd .getOperator ())) {
@@ -1673,7 +1673,7 @@ public Void visit(AssignmentExpression nd, SuccessorInfo i) {
16731673 visitWithSuccessors (nd .getLeft (), union (First .of (nd .getRight ()), i .getAllSuccessors ()));
16741674 }
16751675
1676- visitWithSuccessors (nd .getRight (), First . of ( nd ) ); // from right to assignment.
1676+ visitWithSuccessors (nd .getRight (), nd ); // from right to assignment.
16771677
16781678 writeSuccessors (nd , i .getGuardedSuccessors (nd ));
16791679 } else {
Original file line number Diff line number Diff line change @@ -556,7 +556,7 @@ hasLocation(#20168,#20109)
556556successor(#20161,#20164)
557557successor(#20164,#20165)
558558successor(#20164,#20168)
559- successor(#20165,#20164 )
559+ successor(#20165,#20162 )
560560successor(#20162,#20168)
561561successor(#20156,#20159)
562562#20169=*
@@ -569,7 +569,7 @@ hasLocation(#20170,#20093)
569569successor(#20170,#20160)
570570successor(#20159,#20169)
571571successor(#20159,#20170)
572- successor(#20160,#20159 )
572+ successor(#20160,#20157 )
573573successor(#20157,#20161)
574574successor(#20151,#20154)
575575#20171=*
@@ -582,7 +582,7 @@ hasLocation(#20172,#20085)
582582successor(#20172,#20156)
583583successor(#20154,#20171)
584584successor(#20154,#20172)
585- successor(#20155,#20154 )
585+ successor(#20155,#20152 )
586586successor(#20152,#20156)
587587successor(#20141,#20147)
588588successor(#20150,#20143)
@@ -601,7 +601,7 @@ hasLocation(#20174,#20063)
601601successor(#20174,#20134)
602602successor(#20139,#20173)
603603successor(#20139,#20174)
604- successor(#20140,#20139 )
604+ successor(#20140,#20137 )
605605successor(#20137,#20134)
606606successor(#20136,#20139)
607607successor(#20134,#20141)
Original file line number Diff line number Diff line change @@ -1495,6 +1495,16 @@ module DataFlow {
14951495 predExpr = succExpr .( NonNullAssertion ) .getExpression ( )
14961496 or
14971497 predExpr = succExpr .( ExpressionWithTypeArguments ) .getExpression ( )
1498+ or
1499+ (
1500+ succExpr instanceof AssignLogOrExpr or
1501+ succExpr instanceof AssignLogAndExpr or
1502+ succExpr instanceof AssignNullishCoalescingExpr
1503+ ) and
1504+ (
1505+ predExpr = succExpr .( CompoundAssignExpr ) .getLhs ( ) or
1506+ predExpr = succExpr .( CompoundAssignExpr ) .getRhs ( )
1507+ )
14981508 )
14991509 or
15001510 // flow from 'this' parameter into 'this' expressions
Original file line number Diff line number Diff line change 1+ function f ( ) {
2+ let foo ;
3+ if ( bar ) foo ||= [ ] ;
4+ if ( foo ) ;
5+ } ;
6+
7+ function g ( ) {
8+ let foo ;
9+ if ( bar ) foo ??= [ ] ;
10+ if ( foo ) ;
11+ } ;
12+
13+ function h ( ) {
14+ let foo = true ;
15+ if ( bar ) foo &&= false ;
16+ if ( foo ) ;
17+ }
You can’t perform that action at this time.
0 commit comments