@@ -204,15 +204,21 @@ class IfExprTree extends PostOrderTree instanceof IfExpr {
204
204
child = [ super .getCondition ( ) , super .getThen ( ) , super .getElse ( ) ]
205
205
}
206
206
207
+ ConditionalCompletion conditionCompletion ( Completion c ) {
208
+ if super .getCondition ( ) instanceof LetExpr
209
+ then result = c .( MatchCompletion )
210
+ else result = c .( BooleanCompletion )
211
+ }
212
+
207
213
override predicate succ ( AstNode pred , AstNode succ , Completion c ) {
208
214
// Edges from the condition to the branches
209
215
last ( super .getCondition ( ) , pred , c ) and
210
216
(
211
- first ( super .getThen ( ) , succ ) and c . ( BooleanCompletion ) .succeeded ( )
217
+ first ( super .getThen ( ) , succ ) and this . conditionCompletion ( c ) .succeeded ( )
212
218
or
213
- first ( super .getElse ( ) , succ ) and c . ( BooleanCompletion ) .failed ( )
219
+ first ( super .getElse ( ) , succ ) and this . conditionCompletion ( c ) .failed ( )
214
220
or
215
- not super .hasElse ( ) and succ = this and c . ( BooleanCompletion ) .failed ( )
221
+ not super .hasElse ( ) and succ = this and this . conditionCompletion ( c ) .failed ( )
216
222
)
217
223
or
218
224
// An edge from the then branch to the last node
@@ -235,8 +241,11 @@ class IndexExprTree extends StandardPostOrderTree instanceof IndexExpr {
235
241
}
236
242
}
237
243
238
- class LetExprTree extends StandardPostOrderTree instanceof LetExpr {
239
- override ControlFlowTree getChildNode ( int i ) { i = 0 and result = super .getExpr ( ) }
244
+ // `LetExpr` is a pre-order tree such that the pattern itself ends up
245
+ // dominating successors in the graph in the same way that patterns do in
246
+ // `match` expressions.
247
+ class LetExprTree extends StandardPreOrderTree instanceof LetExpr {
248
+ override ControlFlowTree getChildNode ( int i ) { i = 0 and result = super .getPat ( ) }
240
249
}
241
250
242
251
// We handle `let` statements with trivial patterns separately as they don't
0 commit comments