Skip to content

Commit 582a228

Browse files
Kenoaviatesk
authored andcommitted
inference: Guard TypeVar special case against vararg (#52721)
Fix #52613 by making the TypeVar special case in inference check for vararg first. There's nothing the special case can really do with vararg anyway, so fall back to the ordinary abstract call handling.
1 parent a2ffa91 commit 582a228

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

base/compiler/abstractinterpretation.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2021,10 +2021,10 @@ function abstract_call_known(interp::AbstractInterpreter, @nospecialize(f),
20212021
elseif isa(f, Core.OpaqueClosure)
20222022
# calling an OpaqueClosure about which we have no information returns no information
20232023
return CallMeta(typeof(f).parameters[2], Effects(), NoCallInfo())
2024-
elseif f === TypeVar
2024+
elseif f === TypeVar && !isvarargtype(argtypes[end])
20252025
# Manually look through the definition of TypeVar to
20262026
# make sure to be able to get `PartialTypeVar`s out.
2027-
(la < 2 || la > 4) && return CallMeta(Bottom, EFFECTS_THROWS, NoCallInfo())
2027+
2 la 4 || return CallMeta(Bottom, EFFECTS_THROWS, NoCallInfo())
20282028
n = argtypes[2]
20292029
ub_var = Const(Any)
20302030
lb_var = Const(Union{})

test/compiler/inference.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5129,3 +5129,6 @@ let TV = TypeVar(:T)
51295129
some = Some{Any}((TV, t))
51305130
@test abstract_call_unionall_vararg(some) isa UnionAll
51315131
end
5132+
5133+
# Issue #52613
5134+
@test (code_typed((Any,)) do x; TypeVar(x...); end)[1][2] === TypeVar

0 commit comments

Comments
 (0)