Skip to content

Commit

Permalink
inference: Guard TypeVar special case against vararg (#52721)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Keno authored Jan 4, 2024
1 parent f9b27b3 commit ec686c3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 2 additions & 2 deletions base/compiler/abstractinterpretation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2098,10 +2098,10 @@ function abstract_call_known(interp::AbstractInterpreter, @nospecialize(f),
elseif isa(f, Core.OpaqueClosure)
# calling an OpaqueClosure about which we have no information returns no information
return CallMeta(typeof(f).parameters[2], Any, Effects(), NoCallInfo())
elseif f === TypeVar
elseif f === TypeVar && !isvarargtype(argtypes[end])
# Manually look through the definition of TypeVar to
# make sure to be able to get `PartialTypeVar`s out.
(la < 2 || la > 4) && return CallMeta(Bottom, Any, EFFECTS_THROWS, NoCallInfo())
2 la 4 || return CallMeta(Bottom, Any, EFFECTS_THROWS, NoCallInfo())
n = argtypes[2]
ub_var = Const(Any)
lb_var = Const(Union{})
Expand Down
3 changes: 3 additions & 0 deletions test/compiler/inference.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5614,3 +5614,6 @@ end
let 𝕃 = Core.Compiler.fallback_lattice
@test apply_type_tfunc(𝕃, Const(Tuple{Vararg{Any,N}} where N), Int) == Type{NTuple{_A, Any}} where _A
end

# Issue #52613
@test (code_typed((Any,)) do x; TypeVar(x...); end)[1][2] === TypeVar

2 comments on commit ec686c3

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Executing the daily package evaluation, I will reply here when finished:

@nanosoldier runtests(isdaily = true)

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your job failed: failed to upload test log.

Please sign in to comment.