Skip to content

Commit

Permalink
inference: handle Vararg in abstract_call_unionall for argtypes
Browse files Browse the repository at this point in the history
… computed by `abstract_apply` (#51393)

This commit adds special handling for `Vararg` types that may appear at
the end of `argtypes`, as computed by `abstract_apply`. Even though PR

within the abstract state, they can still be part of `argtypes`. As a
result, this kind of special handling is still necessary. It remains an
open question whether we can refactor `abstract_apply` to prevent
`Vararg`s from appearing in `argtypes` in the first place.
  • Loading branch information
aviatesk committed Sep 26, 2023
1 parent 491dfb5 commit f9ef654
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
7 changes: 6 additions & 1 deletion base/compiler/abstractinterpretation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1874,7 +1874,12 @@ function abstract_call_unionall(interp::AbstractInterpreter, argtypes::Vector{An
a2 = argtypes[2]
a3 = argtypes[3]
= (typeinf_lattice(interp))
nothrow = a2 ᵢ TypeVar && (a3 ᵢ Type || a3 ᵢ TypeVar)
if isvarargtype(a3)
a3 = unwrapva(a3)
nothrow = false
else
nothrow = a2 ᵢ TypeVar && (a3 ᵢ Type || a3 ᵢ TypeVar)
end
if isa(a3, Const)
body = a3.val
elseif isType(a3)
Expand Down
7 changes: 6 additions & 1 deletion test/compiler/inference.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import Core.Compiler: Const, Conditional, ⊑, ReturnNode, GotoIfNot
isdispatchelem(@nospecialize x) = !isa(x, Type) || Core.Compiler.isdispatchelem(x)

using Random, Core.IR
using InteractiveUtils: code_llvm
using InteractiveUtils

include("irutils.jl")

Expand Down Expand Up @@ -5101,3 +5101,8 @@ end |> only === Val{5}
@test fully_eliminated() do
length(continue_const_prop(1, 5))
end

# https://github.com/JuliaLang/julia/issues/51310
@test code_typed() do
b{c} = d...
end |> only |> first isa Core.CodeInfo

0 comments on commit f9ef654

Please sign in to comment.