Skip to content

Commit f24a93a

Browse files
vtjnashaviatesk
andauthored
inference: fix return_type_tfunc modeling of concrete functions (#51042)
The `aft` parameter is a value already, so we should be checking it in the value domain, not the type domain like `tt`. That check happens to already be done (somewhat unnecessarily) earlier in the function. Fixes #40606 --------- Co-authored-by: Shuhei Kadowaki <[email protected]>
1 parent ca1a54a commit f24a93a

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

base/compiler/tfuncs.jl

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2638,13 +2638,15 @@ function return_type_tfunc(interp::AbstractInterpreter, argtypes::Vector{Any}, s
26382638

26392639
if length(argtypes) == 3
26402640
aft = widenslotwrapper(argtypes[2])
2641-
if !isa(aft, Const) && !(isType(aft) && !has_free_typevars(aft)) &&
2642-
!(isconcretetype(aft) && !(aft <: Builtin))
2643-
return UNKNOWN
2644-
end
26452641
argtypes_vec = Any[aft, af_argtype.parameters...]
26462642
else
26472643
argtypes_vec = Any[af_argtype.parameters...]
2644+
isempty(argtypes_vec) && push!(argtypes_vec, Union{})
2645+
aft = argtypes_vec[1]
2646+
end
2647+
if !(isa(aft, Const) || (isType(aft) && !has_free_typevars(aft)) ||
2648+
(isconcretetype(aft) && !(aft <: Builtin) && !iskindtype(aft)))
2649+
return UNKNOWN
26482650
end
26492651

26502652
if contains_is(argtypes_vec, Union{})
@@ -2677,8 +2679,7 @@ function return_type_tfunc(interp::AbstractInterpreter, argtypes::Vector{Any}, s
26772679
# in two ways: both as being a subtype of this, and
26782680
# because of LimitedAccuracy causes
26792681
return CallMeta(Type{<:rt}, EFFECTS_TOTAL, info)
2680-
elseif (isa(tt, Const) || isconstType(tt)) &&
2681-
(isa(aft, Const) || isconstType(aft))
2682+
elseif isa(tt, Const) || isconstType(tt)
26822683
# input arguments were known for certain
26832684
# XXX: this doesn't imply we know anything about rt
26842685
return CallMeta(Const(rt), EFFECTS_TOTAL, info)

0 commit comments

Comments
 (0)