Skip to content

Commit fd8f97e

Browse files
authored
inference: SCC handling missing for return_type_tfunc (#39375)
This has actually been broken for a long time, so it only got noticed when it caused a regression. Fixes #39361
1 parent c889de7 commit fd8f97e

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

base/compiler/tfuncs.jl

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1619,25 +1619,25 @@ function return_type_tfunc(interp::AbstractInterpreter, argtypes::Vector{Any}, s
16191619
if isa(rt, Const)
16201620
# output was computed to be constant
16211621
return Const(typeof(rt.val))
1622+
end
1623+
rt = widenconst(rt)
1624+
if rt === Bottom || (isconcretetype(rt) && !iskindtype(rt))
1625+
# output cannot be improved so it is known for certain
1626+
return Const(rt)
1627+
elseif !isempty(sv.pclimitations)
1628+
# conservatively express uncertainty of this result
1629+
# in two ways: both as being a subtype of this, and
1630+
# because of LimitedAccuracy causes
1631+
return Type{<:rt}
1632+
elseif (isa(tt, Const) || isconstType(tt)) &&
1633+
(isa(aft, Const) || isconstType(aft))
1634+
# input arguments were known for certain
1635+
# XXX: this doesn't imply we know anything about rt
1636+
return Const(rt)
1637+
elseif isType(rt)
1638+
return Type{rt}
16221639
else
1623-
inaccurate = nothing
1624-
rt isa LimitedAccuracy && (inaccurate = rt.causes; rt = rt.typ)
1625-
rt = widenconst(rt)
1626-
if hasuniquerep(rt) || rt === Bottom
1627-
# output type was known for certain
1628-
return Const(rt)
1629-
elseif inaccurate !== nothing
1630-
return LimitedAccuracy(Type{<:rt}, inaccurate)
1631-
elseif (isa(tt, Const) || isconstType(tt)) &&
1632-
(isa(aft, Const) || isconstType(aft))
1633-
# input arguments were known for certain
1634-
# XXX: this doesn't imply we know anything about rt
1635-
return Const(rt)
1636-
elseif isType(rt)
1637-
return Type{rt}
1638-
else
1639-
return Type{<:rt}
1640-
end
1640+
return Type{<:rt}
16411641
end
16421642
end
16431643
end

0 commit comments

Comments
 (0)