@@ -818,7 +818,7 @@ private module AssignOperationDesugar {
818
818
i in [ 0 .. sao .getNumberOfArguments ( ) ]
819
819
or
820
820
parent = setter and
821
- i = opAssignIndex + 1 and
821
+ i = opAssignIndex and
822
822
child =
823
823
SynthChild ( LocalVariableAccessSynthKind ( TLocalVariableSynth ( sao , opAssignIndex ) ) )
824
824
)
@@ -975,7 +975,7 @@ private module DestructuredAssignDesugar {
975
975
976
976
pragma [ nomagic]
977
977
private predicate destructuredAssignSynthesis ( AstNode parent , int i , Child child ) {
978
- exists ( DestructuredAssignExpr tae |
978
+ exists ( DestructuredAssignExpr tae , int total | total = tae . getNumberOfElements ( ) |
979
979
parent = tae and
980
980
i = - 1 and
981
981
child = SynthChild ( StmtSequenceKind ( ) )
@@ -998,15 +998,13 @@ private module DestructuredAssignDesugar {
998
998
)
999
999
or
1000
1000
parent = seq and
1001
- i = tae . getNumberOfElements ( ) and
1001
+ i = total and
1002
1002
child = SynthChild ( AssignExprKind ( ) )
1003
1003
or
1004
- exists ( AstNode assign | assign = TAssignExprSynth ( seq , tae . getNumberOfElements ( ) ) |
1004
+ exists ( AstNode assign | assign = TAssignExprSynth ( seq , total ) |
1005
1005
parent = assign and
1006
1006
i = 0 and
1007
- child =
1008
- SynthChild ( LocalVariableAccessSynthKind ( TLocalVariableSynth ( tae ,
1009
- tae .getNumberOfElements ( ) ) ) )
1007
+ child = SynthChild ( LocalVariableAccessSynthKind ( TLocalVariableSynth ( tae , total ) ) )
1010
1008
or
1011
1009
parent = assign and
1012
1010
i = 1 and
@@ -1022,12 +1020,10 @@ private module DestructuredAssignDesugar {
1022
1020
restIndex = tae .getRestIndexOrNumberOfElements ( )
1023
1021
|
1024
1022
parent = seq and
1025
- i = j + 1 + tae . getNumberOfElements ( ) and
1023
+ i = j + 1 + total and
1026
1024
child = SynthChild ( AssignExprKind ( ) )
1027
1025
or
1028
- exists ( AstNode assign |
1029
- assign = TAssignExprSynth ( seq , j + 1 + tae .getNumberOfElements ( ) )
1030
- |
1026
+ exists ( AstNode assign | assign = TAssignExprSynth ( seq , j + 1 + total ) |
1031
1027
exists ( LhsWithReceiver mc | mc = elem |
1032
1028
parent = assign and
1033
1029
i = 0 and
@@ -1063,9 +1059,7 @@ private module DestructuredAssignDesugar {
1063
1059
or
1064
1060
parent = TMethodCallSynth ( assign , 1 , _, _, _) and
1065
1061
i = 0 and
1066
- child =
1067
- SynthChild ( LocalVariableAccessSynthKind ( TLocalVariableSynth ( tae ,
1068
- tae .getNumberOfElements ( ) ) ) )
1062
+ child = SynthChild ( LocalVariableAccessSynthKind ( TLocalVariableSynth ( tae , total ) ) )
1069
1063
or
1070
1064
j < restIndex and
1071
1065
parent = TMethodCallSynth ( assign , 1 , _, _, _) and
@@ -1086,14 +1080,14 @@ private module DestructuredAssignDesugar {
1086
1080
child = SynthChild ( IntegerLiteralKind ( j ) )
1087
1081
or
1088
1082
i = 1 and
1089
- child = SynthChild ( IntegerLiteralKind ( restIndex - tae . getNumberOfElements ( ) ) )
1083
+ child = SynthChild ( IntegerLiteralKind ( restIndex - total ) )
1090
1084
)
1091
1085
)
1092
1086
or
1093
1087
j > restIndex and
1094
1088
parent = TMethodCallSynth ( assign , 1 , _, _, _) and
1095
1089
i = 1 and
1096
- child = SynthChild ( IntegerLiteralKind ( j - tae . getNumberOfElements ( ) ) )
1090
+ child = SynthChild ( IntegerLiteralKind ( j - total ) )
1097
1091
)
1098
1092
)
1099
1093
)
@@ -1284,10 +1278,10 @@ private module ForLoopDesugar {
1284
1278
child = childRef ( for .getValue ( ) ) // value is the Enumerable
1285
1279
or
1286
1280
parent = eachCall and
1287
- i = - 2 and
1281
+ i = 1 and
1288
1282
child = SynthChild ( BraceBlockKind ( ) )
1289
1283
or
1290
- exists ( Block block | block = TBraceBlockSynth ( eachCall , - 2 ) |
1284
+ exists ( Block block | block = TBraceBlockSynth ( eachCall , 1 ) |
1291
1285
// block params
1292
1286
parent = block and
1293
1287
i = 0 and
@@ -1534,14 +1528,13 @@ private module SafeNavigationCallDesugar {
1534
1528
i = 1
1535
1529
)
1536
1530
or
1537
- parent = TMethodCallSynth ( ifExpr , 2 , _, _, _) and
1538
- (
1531
+ exists ( int arity | parent = TMethodCallSynth ( ifExpr , 2 , _, _, arity ) |
1539
1532
i = 0 and
1540
1533
child = SynthChild ( local )
1541
1534
or
1542
1535
child = childRef ( call .getArgumentImpl ( i - 1 ) )
1543
1536
or
1544
- child = childRef ( call .getBlockImpl ( ) ) and i = - 2
1537
+ child = childRef ( call .getBlockImpl ( ) ) and i = arity + 1
1545
1538
)
1546
1539
)
1547
1540
)
0 commit comments