Skip to content

Commit

Permalink
fix #41908, inference error in subst_trivial_bounds (#41976)
Browse files Browse the repository at this point in the history
Co-authored-by: Martin Holters <martin.holters@hsu-hh.de>
(cherry picked from commit e2aeefb)
  • Loading branch information
JeffBezanson authored and KristofferC committed Nov 11, 2021
1 parent 6d4a956 commit fa3d502
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
10 changes: 9 additions & 1 deletion base/compiler/utilities.jl
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,15 @@ function subst_trivial_bounds(@nospecialize(atypes))
end
v = atypes.var
if isconcretetype(v.ub) || v.lb === v.ub
return subst_trivial_bounds(atypes{v.ub})
subst = try
atypes{v.ub}
catch
# Note in rare cases a var bound might not be valid to substitute.
nothing
end
if subst !== nothing
return subst_trivial_bounds(subst)
end
end
return UnionAll(v, subst_trivial_bounds(atypes.body))
end
Expand Down
5 changes: 5 additions & 0 deletions test/compiler/inference.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3085,3 +3085,8 @@ end
end
return x
end) === Union{Int, Float64, Char}

# issue #41908
f41908(x::Complex{T}) where {String<:T<:String} = 1
g41908() = f41908(Any[1][1])
@test only(Base.return_types(g41908, ())) <: Int

0 comments on commit fa3d502

Please sign in to comment.