Skip to content

Commit

Permalink
fix #10880, better inference of splatting constant containers
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffBezanson committed Oct 12, 2016
1 parent ec80011 commit 68cc6e8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 4 additions & 2 deletions base/inference.jl
Original file line number Diff line number Diff line change
Expand Up @@ -968,8 +968,10 @@ function precise_container_types(args, types, vtypes::VarTable, sv)
if isa(tti, TypeConstructor)
tti = tti.body
end
if isa(ai, Expr) && ai.head === :call && (abstract_evals_to_constant(ai.args[1], svec, vtypes, sv) ||
abstract_evals_to_constant(ai.args[1], tuple, vtypes, sv))
if isa(ti, Const) && (isa(ti.val, SimpleVector) || isa(ti.val, Tuple))
result[i] = Any[ abstract_eval_constant(x) for x in ti.val ]
elseif isa(ai, Expr) && ai.head === :call && (abstract_evals_to_constant(ai.args[1], svec, vtypes, sv) ||
abstract_evals_to_constant(ai.args[1], tuple, vtypes, sv))
aa = ai.args
result[i] = Any[ (isa(aa[j],Expr) ? aa[j].typ : abstract_eval(aa[j],vtypes,sv)) for j=2:length(aa) ]
if _any(isvarargtype, result[i])
Expand Down
6 changes: 6 additions & 0 deletions test/inference.jl
Original file line number Diff line number Diff line change
Expand Up @@ -415,3 +415,9 @@ gpure(x::Irrational) = fpure(x)
@test @code_typed(gpure(π))[1].pure
@test gpure() == gpure() == gpure()
@test gpure(π) == gpure(π) == gpure(π)

# issue #10880
function cat10880(a, b)
Tuple{a.parameters..., b.parameters...}
end
@inferred cat10880(Tuple{Int8,Int16}, Tuple{Int32})

0 comments on commit 68cc6e8

Please sign in to comment.