Skip to content

Commit d01dec7

Browse files
vtjnashstaticfloat
authored andcommitted
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 (cherry picked from commit fd8f97e)
1 parent 8dee6cd commit d01dec7

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
@@ -1585,25 +1585,25 @@ function return_type_tfunc(interp::AbstractInterpreter, argtypes::Vector{Any}, s
15851585
if isa(rt, Const)
15861586
# output was computed to be constant
15871587
return Const(typeof(rt.val))
1588+
end
1589+
rt = widenconst(rt)
1590+
if rt === Bottom || (isconcretetype(rt) && !iskindtype(rt))
1591+
# output cannot be improved so it is known for certain
1592+
return Const(rt)
1593+
elseif !isempty(sv.pclimitations)
1594+
# conservatively express uncertainty of this result
1595+
# in two ways: both as being a subtype of this, and
1596+
# because of LimitedAccuracy causes
1597+
return Type{<:rt}
1598+
elseif (isa(tt, Const) || isconstType(tt)) &&
1599+
(isa(aft, Const) || isconstType(aft))
1600+
# input arguments were known for certain
1601+
# XXX: this doesn't imply we know anything about rt
1602+
return Const(rt)
1603+
elseif isType(rt)
1604+
return Type{rt}
15881605
else
1589-
inaccurate = nothing
1590-
rt isa LimitedAccuracy && (inaccurate = rt.causes; rt = rt.typ)
1591-
rt = widenconst(rt)
1592-
if hasuniquerep(rt) || rt === Bottom
1593-
# output type was known for certain
1594-
return Const(rt)
1595-
elseif inaccurate !== nothing
1596-
return LimitedAccuracy(Type{<:rt}, inaccurate)
1597-
elseif (isa(tt, Const) || isconstType(tt)) &&
1598-
(isa(aft, Const) || isconstType(aft))
1599-
# input arguments were known for certain
1600-
# XXX: this doesn't imply we know anything about rt
1601-
return Const(rt)
1602-
elseif isType(rt)
1603-
return Type{rt}
1604-
else
1605-
return Type{<:rt}
1606-
end
1606+
return Type{<:rt}
16071607
end
16081608
end
16091609
end

0 commit comments

Comments
 (0)