@@ -287,6 +287,16 @@ private predicate typeEquality(AstNode n1, TypePath prefix1, AstNode n2, TypePat
287287 prefix2 .isEmpty ( )
288288 )
289289 )
290+ or
291+ // an array list expression (`[1, 2, 3]`) has the type of the first (any) element
292+ n1 .( ArrayListExpr ) .getExpr ( 0 ) = n2 and
293+ prefix1 = TypePath:: singleton ( TArrayTypeParameter ( ) ) and
294+ prefix2 .isEmpty ( )
295+ or
296+ // an array repeat expression (`[1; 3]`) has the type of the repeat operand
297+ n1 .( ArrayRepeatExpr ) .getRepeatOperand ( ) = n2 and
298+ prefix1 = TypePath:: singleton ( TArrayTypeParameter ( ) ) and
299+ prefix2 .isEmpty ( )
290300}
291301
292302pragma [ nomagic]
@@ -1124,23 +1134,6 @@ private Type inferIndexExprType(IndexExpr ie, TypePath path) {
11241134 )
11251135}
11261136
1127- pragma [ nomagic]
1128- private Type inferArrayExprType ( ArrayExpr ae , TypePath path ) {
1129- // an array list expression (`[1, 2, 3]`) has the type of the first (any) element
1130- exists ( Type type0 , TypePath path0 |
1131- type0 = inferType ( ae .( ArrayListExpr ) .getExpr ( 0 ) , path0 ) and
1132- result = type0 and
1133- path = TypePath:: cons ( any ( ArrayTypeParameter tp ) , path0 )
1134- )
1135- or
1136- // an array repeat expression (`[1; 3]`) has the type of the repeat operand
1137- exists ( Type type0 , TypePath path0 |
1138- type0 = inferType ( ae .( ArrayRepeatExpr ) .getRepeatOperand ( ) , path0 ) and
1139- result = type0 and
1140- path = TypePath:: cons ( any ( ArrayTypeParameter tp ) , path0 )
1141- )
1142- }
1143-
11441137pragma [ nomagic]
11451138private Type inferForLoopExprType ( AstNode n , TypePath path ) {
11461139 // type of iterable -> type of pattern (loop variable)
@@ -1470,8 +1463,6 @@ private module Cached {
14701463 or
14711464 result = inferIndexExprType ( n , path )
14721465 or
1473- result = inferArrayExprType ( n , path )
1474- or
14751466 result = inferForLoopExprType ( n , path )
14761467 }
14771468}
0 commit comments