@@ -331,9 +331,11 @@ public Node visit(MemberDefinition<?> nd, Void v) {
331331 return nd .getKey ().accept (this , v );
332332 }
333333
334- // for binary operators, the operands come first (but not for LogicalExpression , see above)
334+ // for binary operators, the operands come first (but not for short-circuiting expressions) , see above)
335335 @ Override
336336 public Node visit (BinaryExpression nd , Void v ) {
337+ if ("??" .equals (nd .getOperator ()))
338+ return nd ;
337339 return nd .getLeft ().accept (this , v );
338340 }
339341
@@ -1583,8 +1585,16 @@ protected void visitAssign(INode assgn, INode lhs, Expression rhs) {
15831585
15841586 @ Override
15851587 public Void visit (BinaryExpression nd , SuccessorInfo i ) {
1586- this .seq (nd .getLeft (), nd .getRight (), nd );
1587- succ (nd , i .getGuardedSuccessors (nd ));
1588+ if ("??" .equals (nd .getOperator ())) {
1589+ // the nullish coalescing operator is short-circuiting, but we do not add guards for it
1590+ succ (nd , First .of (nd .getLeft ()));
1591+ Object leftSucc = union (First .of (nd .getRight ()), i .getAllSuccessors ()); // short-circuiting happens with both truthy and falsy values
1592+ visit (nd .getLeft (), leftSucc , null );
1593+ nd .getRight ().accept (this , i );
1594+ } else {
1595+ this .seq (nd .getLeft (), nd .getRight (), nd );
1596+ succ (nd , i .getGuardedSuccessors (nd ));
1597+ }
15881598 return null ;
15891599 }
15901600
0 commit comments