Skip to content

Commit

Permalink
fix JuliaLang#41908, inference error in subst_trivial_bounds (JuliaLa…
Browse files Browse the repository at this point in the history
…ng#41976)

Co-authored-by: Martin Holters <martin.holters@hsu-hh.de>
  • Loading branch information
2 people authored and LilithHafner committed Feb 22, 2022
1 parent 4af5364 commit 67a2b5d
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 @@ -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
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 @@ -3408,3 +3408,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 67a2b5d

Please sign in to comment.