Skip to content

Commit 5f86e29

Browse files
committed
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 792a35b commit 5f86e29

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

base/compiler/abstractinterpretation.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2098,7 +2098,7 @@ 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.
21042104
(la < 2 || la > 4) && return CallMeta(Bottom, Any, EFFECTS_THROWS, NoCallInfo())

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)