Skip to content

Commit c9734e4

Browse files
committed
inference: handle Vararg in abstract_call_unionall
1 parent 7f37e70 commit c9734e4

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

base/compiler/abstractinterpretation.jl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1858,7 +1858,12 @@ function abstract_call_unionall(interp::AbstractInterpreter, argtypes::Vector{An
18581858
a2 = argtypes[2]
18591859
a3 = argtypes[3]
18601860
= (typeinf_lattice(interp))
1861-
nothrow = a2 ᵢ TypeVar && (a3 ᵢ Type || a3 ᵢ TypeVar)
1861+
if isvarargtype(a3)
1862+
a3 = unwrapva(a3)
1863+
nothrow = false
1864+
else
1865+
nothrow = a2 ᵢ TypeVar && (a3 ᵢ Type || a3 ᵢ TypeVar)
1866+
end
18621867
if isa(a3, Const)
18631868
body = a3.val
18641869
elseif isType(a3)
@@ -2253,7 +2258,6 @@ function abstract_eval_value_expr(interp::AbstractInterpreter, e::Expr, vtypes::
22532258
return Any
22542259
end
22552260

2256-
22572261
function abstract_eval_value(interp::AbstractInterpreter, @nospecialize(e), vtypes::Union{VarTable,Nothing}, sv::AbsIntState)
22582262
if isa(e, Expr)
22592263
return abstract_eval_value_expr(interp, e, vtypes, sv)

test/compiler/inference.jl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import Core.Compiler: Const, Conditional, ⊑, ReturnNode, GotoIfNot
55
isdispatchelem(@nospecialize x) = !isa(x, Type) || Core.Compiler.isdispatchelem(x)
66

77
using Random, Core.IR
8-
using InteractiveUtils: code_llvm
8+
using InteractiveUtils
99

1010
include("irutils.jl")
1111

@@ -5230,3 +5230,8 @@ end |> only == Val{false}
52305230
@test Base.return_types((Bool,)) do b
52315231
Val(Core.Intrinsics.or_int(true, b))
52325232
end |> only == Val{true}
5233+
5234+
# https://github.com/JuliaLang/julia/issues/51310
5235+
@test code_typed() do
5236+
b{c} = d...
5237+
end |> only |> first isa Core.CodeInfo

0 commit comments

Comments
 (0)