Skip to content

Commit bd66edb

Browse files
committed
Revert "inference: follow up the Vararg fix in abstract_call_unionall (#51403)"
This reverts commit ae8f9ad.
1 parent ddec9e4 commit bd66edb

File tree

2 files changed

+30
-44
lines changed

2 files changed

+30
-44
lines changed

base/compiler/abstractinterpretation.jl

Lines changed: 30 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1869,50 +1869,44 @@ function abstract_call_builtin(interp::AbstractInterpreter, f::Builtin, (; fargs
18691869
end
18701870

18711871
function abstract_call_unionall(interp::AbstractInterpreter, argtypes::Vector{Any})
1872-
na = length(argtypes)
1873-
if isvarargtype(argtypes[end])
1874-
if na 2
1875-
return CallMeta(Any, EFFECTS_THROWS, NoCallInfo())
1876-
elseif na > 4
1877-
return CallMeta(Bottom, EFFECTS_THROWS, NoCallInfo())
1878-
end
1879-
a2 = argtypes[2]
1880-
a3 = unwrapva(argtypes[3])
1881-
nothrow = false
1882-
elseif na == 3
1872+
if length(argtypes) == 3
1873+
canconst = true
18831874
a2 = argtypes[2]
18841875
a3 = argtypes[3]
18851876
= (typeinf_lattice(interp))
1886-
nothrow = a2 ᵢ TypeVar && (a3 ᵢ Type || a3 ᵢ TypeVar)
1887-
else
1888-
return CallMeta(Bottom, EFFECTS_THROWS, NoCallInfo())
1889-
end
1890-
canconst = true
1891-
if isa(a3, Const)
1892-
body = a3.val
1893-
elseif isType(a3)
1894-
body = a3.parameters[1]
1895-
canconst = false
1896-
else
1897-
return CallMeta(Any, Effects(EFFECTS_TOTAL; nothrow), NoCallInfo())
1898-
end
1899-
if !(isa(body, Type) || isa(body, TypeVar))
1900-
return CallMeta(Any, EFFECTS_THROWS, NoCallInfo())
1901-
end
1902-
if has_free_typevars(body)
1903-
if isa(a2, Const)
1904-
tv = a2.val
1905-
elseif isa(a2, PartialTypeVar)
1906-
tv = a2.tv
1877+
if isvarargtype(a3)
1878+
a3 = unwrapva(a3)
1879+
nothrow = false
1880+
else
1881+
nothrow = a2 ᵢ TypeVar && (a3 ᵢ Type || a3 ᵢ TypeVar)
1882+
end
1883+
if isa(a3, Const)
1884+
body = a3.val
1885+
elseif isType(a3)
1886+
body = a3.parameters[1]
19071887
canconst = false
19081888
else
1889+
return CallMeta(Any, Effects(EFFECTS_TOTAL; nothrow), NoCallInfo())
1890+
end
1891+
if !(isa(body, Type) || isa(body, TypeVar))
19091892
return CallMeta(Any, EFFECTS_THROWS, NoCallInfo())
19101893
end
1911-
isa(tv, TypeVar) || return CallMeta(Any, EFFECTS_THROWS, NoCallInfo())
1912-
body = UnionAll(tv, body)
1894+
if has_free_typevars(body)
1895+
if isa(a2, Const)
1896+
tv = a2.val
1897+
elseif isa(a2, PartialTypeVar)
1898+
tv = a2.tv
1899+
canconst = false
1900+
else
1901+
return CallMeta(Any, EFFECTS_THROWS, NoCallInfo())
1902+
end
1903+
isa(tv, TypeVar) || return CallMeta(Any, EFFECTS_THROWS, NoCallInfo())
1904+
body = UnionAll(tv, body)
1905+
end
1906+
ret = canconst ? Const(body) : Type{body}
1907+
return CallMeta(ret, Effects(EFFECTS_TOTAL; nothrow), NoCallInfo())
19131908
end
1914-
ret = canconst ? Const(body) : Type{body}
1915-
return CallMeta(ret, Effects(EFFECTS_TOTAL; nothrow), NoCallInfo())
1909+
return CallMeta(Bottom, EFFECTS_THROWS, NoCallInfo())
19161910
end
19171911

19181912
function abstract_invoke(interp::AbstractInterpreter, (; fargs, argtypes)::ArgInfo, si::StmtInfo, sv::AbsIntState)

test/compiler/inference.jl

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5106,11 +5106,3 @@ end
51065106
@test code_typed() do
51075107
b{c} = d...
51085108
end |> only |> first isa Core.CodeInfo
5109-
5110-
abstract_call_unionall_vararg(some::Some{Any}) = UnionAll(some.value...)
5111-
@test only(Base.return_types(abstract_call_unionall_vararg)) !== Union{}
5112-
let TV = TypeVar(:T)
5113-
t = Vector{TV}
5114-
some = Some{Any}((TV, t))
5115-
@test abstract_call_unionall_vararg(some) isa UnionAll
5116-
end

0 commit comments

Comments
 (0)