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 Aug 25, 2021
1 parent 7a79ed1 commit f3d2bca
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 @@ -155,7 +155,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 @@ -3411,3 +3411,8 @@ end
@test @inferred(f40177(T)) == fieldtype(T, 1)
end
end

# 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 f3d2bca

Please sign in to comment.