Skip to content

Commit 6eb535d

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 79684ad commit 6eb535d

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
@@ -5134,3 +5134,6 @@ end
51345134
let 𝕃 = Core.Compiler.fallback_lattice
51355135
@test apply_type_tfunc(𝕃, Const(Tuple{Vararg{Any,N}} where N), Int) == Type{NTuple{_A, Any}} where _A
51365136
end
5137+
5138+
# Issue #52613
5139+
@test (code_typed((Any,)) do x; TypeVar(x...); end)[1][2] === TypeVar

0 commit comments

Comments
 (0)