Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion base/compiler/utilities.jl
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,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
Comment on lines +159 to +167
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh boy, this is a nice example for justifying a

try
catch
else
    # code that runs when no exception was thrown
end

construct. But given that we don't have it, I guess this is fine.

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 @@ -3403,3 +3403,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