@@ -390,6 +390,7 @@ function nfields_tfunc(@nospecialize(x))
390
390
end
391
391
add_tfunc (nfields, 1 , 1 , nfields_tfunc, 1 )
392
392
add_tfunc (Core. _expr, 1 , INT_INF, (@nospecialize args... )-> Expr, 100 )
393
+ add_tfunc (svec, 0 , INT_INF, (@nospecialize args... )-> SimpleVector, 20 )
393
394
function typevar_tfunc (@nospecialize (n), @nospecialize (lb_arg), @nospecialize (ub_arg))
394
395
lb = Union{}
395
396
ub = Any
@@ -1300,6 +1301,26 @@ function tuple_tfunc(atypes::Vector{Any})
1300
1301
return anyinfo ? PartialStruct (typ, atypes) : typ
1301
1302
end
1302
1303
1304
+ function arrayref_tfunc (@nospecialize (boundscheck), @nospecialize (a), @nospecialize i... )
1305
+ a = widenconst (a)
1306
+ if a <: Array
1307
+ if isa (a, DataType) && (isa (a. parameters[1 ], Type) || isa (a. parameters[1 ], TypeVar))
1308
+ # TODO : the TypeVar case should not be needed here
1309
+ a = a. parameters[1 ]
1310
+ return isa (a, TypeVar) ? a. ub : a
1311
+ elseif isa (a, UnionAll) && ! has_free_typevars (a)
1312
+ unw = unwrap_unionall (a)
1313
+ if isa (unw, DataType)
1314
+ return rewrap_unionall (unw. parameters[1 ], a)
1315
+ end
1316
+ end
1317
+ end
1318
+ return Any
1319
+ end
1320
+ add_tfunc (arrayref, 3 , INT_INF, arrayref_tfunc, 20 )
1321
+ add_tfunc (const_arrayref, 3 , INT_INF, arrayref_tfunc, 20 )
1322
+ add_tfunc (arrayset, 4 , INT_INF, (@nospecialize (boundscheck), @nospecialize (a), @nospecialize (v), @nospecialize i... )-> a, 20 )
1323
+
1303
1324
function array_type_undefable (@nospecialize (a))
1304
1325
if isa (a, Union)
1305
1326
return array_type_undefable (a. a) || array_type_undefable (a. b)
@@ -1390,36 +1411,8 @@ end
1390
1411
1391
1412
function builtin_tfunction (interp:: AbstractInterpreter , @nospecialize (f), argtypes:: Array{Any,1} ,
1392
1413
sv:: Union{InferenceState,Nothing} )
1393
- isva = ! isempty (argtypes) && isvarargtype (argtypes[end ])
1394
1414
if f === tuple
1395
1415
return tuple_tfunc (argtypes)
1396
- elseif f === svec
1397
- return SimpleVector
1398
- elseif f === arrayset
1399
- if length (argtypes) < 4
1400
- isva && return Any
1401
- return Bottom
1402
- end
1403
- return argtypes[2 ]
1404
- elseif f === arrayref || f === const_arrayref
1405
- if length (argtypes) < 3
1406
- isva && return Any
1407
- return Bottom
1408
- end
1409
- a = widenconst (argtypes[2 ])
1410
- if a <: Array
1411
- if isa (a, DataType) && (isa (a. parameters[1 ], Type) || isa (a. parameters[1 ], TypeVar))
1412
- # TODO : the TypeVar case should not be needed here
1413
- a = a. parameters[1 ]
1414
- return isa (a, TypeVar) ? a. ub : a
1415
- elseif isa (a, UnionAll) && ! has_free_typevars (a)
1416
- unw = unwrap_unionall (a)
1417
- if isa (unw, DataType)
1418
- return rewrap_unionall (unw. parameters[1 ], a)
1419
- end
1420
- end
1421
- end
1422
- return Any
1423
1416
elseif f === invoke
1424
1417
if length (argtypes) > 1 && sv != = nothing && (isa (argtypes[1 ], Const) || isa (argtypes[1 ], Type))
1425
1418
if isa (argtypes[1 ], Const)
@@ -1464,7 +1457,7 @@ function builtin_tfunction(interp::AbstractInterpreter, @nospecialize(f), argtyp
1464
1457
tf = T_FFUNC_VAL[fidx]
1465
1458
end
1466
1459
tf = tf:: Tuple{Int, Int, Any}
1467
- if isva
1460
+ if ! isempty (argtypes) && isvarargtype (argtypes[ end ])
1468
1461
if length (argtypes) - 1 > tf[2 ]
1469
1462
# definitely too many arguments
1470
1463
return Bottom
0 commit comments