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
8 changes: 6 additions & 2 deletions base/compiler/typelimits.jl
Original file line number Diff line number Diff line change
Expand Up @@ -414,8 +414,12 @@ function tmerge(@nospecialize(typea), @nospecialize(typeb))
fields = Vector{Any}(undef, type_nfields)
anyconst = false
for i = 1:type_nfields
ity = tmerge(getfield_tfunc(typea, Const(i)),
getfield_tfunc(typeb, Const(i)))
ai = getfield_tfunc(typea, Const(i))
bi = getfield_tfunc(typeb, Const(i))
ity = tmerge(ai, bi)
if ai === Union{} || bi === Union{}
ity = widenconst(ity)
end
fields[i] = ity
anyconst |= has_nontrivial_const_info(ity)
end
Expand Down
20 changes: 20 additions & 0 deletions test/compiler/inference.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3988,3 +3988,23 @@ end |> only == Int
end
end |> only === Union{UnionNarrowingByIsdefinedA, UnionNarrowingByIsdefinedB}
end

# issue #43784
@testset "issue #43784" begin
init = Base.ImmutableDict{Any,Any}()
a = Const(init)
b = Core.PartialStruct(typeof(init), Any[Const(init), Any, Any])
c = Core.Compiler.tmerge(a, b)
@test ⊑(a, c)
@test ⊑(b, c)

@test @eval Module() begin
const ginit = Base.ImmutableDict{Any,Any}()
Base.return_types() do
g = ginit
while true
g = Base.ImmutableDict(g, 1=>2)
end
end |> only === Union{}
end
end