Skip to content

Commit a3e04a2

Browse files
Kenoaviatesk
authored andcommitted
inference: Guard TypeVar special case against vararg
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 0f6c72c commit a3e04a2

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
@@ -2098,10 +2098,10 @@ function abstract_call_known(interp::AbstractInterpreter, @nospecialize(f),
20982098
elseif isa(f, Core.OpaqueClosure)
20992099
# calling an OpaqueClosure about which we have no information returns no information
21002100
return CallMeta(typeof(f).parameters[2], Any, Effects(), NoCallInfo())
2101-
elseif f === TypeVar
2101+
elseif f === TypeVar && !isvarargtype(argtypes[end])
21022102
# Manually look through the definition of TypeVar to
21032103
# make sure to be able to get `PartialTypeVar`s out.
2104-
(la < 2 || la > 4) && return CallMeta(Bottom, Any, EFFECTS_THROWS, NoCallInfo())
2104+
2 la 4 || return CallMeta(Bottom, Any, EFFECTS_THROWS, NoCallInfo())
21052105
n = argtypes[2]
21062106
ub_var = Const(Any)
21072107
lb_var = Const(Union{})

test/compiler/inference.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5614,3 +5614,6 @@ end
56145614
let 𝕃 = Core.Compiler.fallback_lattice
56155615
@test apply_type_tfunc(𝕃, Const(Tuple{Vararg{Any,N}} where N), Int) == Type{NTuple{_A, Any}} where _A
56165616
end
5617+
5618+
# Issue #52613
5619+
@test (code_typed((Any,)) do x; TypeVar(x...); end)[1][2] === TypeVar

0 commit comments

Comments
 (0)