Skip to content

Commit

Permalink
fix #32465, inference of splatting unionall NamedTuple types
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffBezanson committed Jul 3, 2019
1 parent a63f2e9 commit 9f21338
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
7 changes: 4 additions & 3 deletions base/compiler/abstractinterpretation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -442,10 +442,11 @@ function precise_container_type(@nospecialize(typ), vtypes::VarTable, sv::Infere
tti0 = widenconst(typ)
tti = unwrap_unionall(tti0)
if isa(tti, DataType) && tti.name === NamedTuple_typename
tti0 = tti.parameters[2]
while isa(tti0, TypeVar)
tti0 = tti0.ub
tti = tti.parameters[2]
while isa(tti, TypeVar)
tti = tti.ub
end
tti0 = rewrap_unionall(tti, tti0)
end
if isa(tti, Union)
utis = uniontypes(tti)
Expand Down
6 changes: 6 additions & 0 deletions test/compiler/inference.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1934,6 +1934,12 @@ Base.iterate(::Iterator27434, ::Any) = nothing
@test @inferred((1, 2, 3) == (1, 2, 3))
@test Core.Compiler.return_type(splat27434, Tuple{typeof(Iterators.repeated(1))}) == Union{}

# issue #32465
let rt = Base.return_types(splat27434, (NamedTuple{(:x,), Tuple{T}} where T,))
@test rt == Any[Tuple{Any}]
@test !Base.has_free_typevars(rt[1])
end

# issue #27078
f27078(T::Type{S}) where {S} = isa(T, UnionAll) ? f27078(T.body) : T
T27078 = Vector{Vector{T}} where T
Expand Down

0 comments on commit 9f21338

Please sign in to comment.