Skip to content

Commit

Permalink
inference: handle Vararg in abstract_call_unionall
Browse files Browse the repository at this point in the history
  • Loading branch information
aviatesk committed Sep 19, 2023
1 parent 7f37e70 commit c9734e4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
8 changes: 6 additions & 2 deletions base/compiler/abstractinterpretation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1858,7 +1858,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 Expand Up @@ -2253,7 +2258,6 @@ function abstract_eval_value_expr(interp::AbstractInterpreter, e::Expr, vtypes::
return Any
end


function abstract_eval_value(interp::AbstractInterpreter, @nospecialize(e), vtypes::Union{VarTable,Nothing}, sv::AbsIntState)
if isa(e, Expr)
return abstract_eval_value_expr(interp, e, vtypes, sv)
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 @@ -5230,3 +5230,8 @@ end |> only == Val{false}
@test Base.return_types((Bool,)) do b
Val(Core.Intrinsics.or_int(true, b))
end |> only == Val{true}

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

0 comments on commit c9734e4

Please sign in to comment.