Skip to content

Commit

Permalink
fix #13183, infinite recursion in compiler via static parameter
Browse files Browse the repository at this point in the history
The static parameter was causing a type to be wrapped in a TypeVar,
hiding it from limit_tuple_depth.
  • Loading branch information
JeffBezanson committed Sep 17, 2015
1 parent 01d3178 commit 9f72db1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
6 changes: 5 additions & 1 deletion base/inference.jl
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,8 @@ function limit_type_depth(t::ANY, d::Int, cov::Bool, vars)
if d > MAX_TYPE_DEPTH
R = t.name.primary
else
Q = map(x->limit_type_depth(x, d+1, false, vars), P)
stillcov = cov && (t.name === Tuple.name)
Q = map(x->limit_type_depth(x, d+1, stillcov, vars), P)
if !cov && any(p->contains_is(vars,p), Q)
R = t.name.primary
inexact = true
Expand Down Expand Up @@ -578,6 +579,9 @@ const limit_tuple_depth_ = function (t,d::Int)
# may have to recur into other stuff in the future too.
return Union{map(x->limit_tuple_depth_(x,d+1), t.types)...}
end
if isa(t,TypeVar)
return limit_tuple_depth_(t.ub, d)
end
if !(isa(t,DataType) && t.name === Tuple.name)
return t
end
Expand Down
4 changes: 4 additions & 0 deletions test/core.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3375,3 +3375,7 @@ immutable EmptyIIOtherField13175
end
@test EmptyIIOtherField13175(EmptyImmutable13175(), 1.0) == EmptyIIOtherField13175(EmptyImmutable13175(), 1.0)
@test EmptyIIOtherField13175(EmptyImmutable13175(), 1.0) != EmptyIIOtherField13175(EmptyImmutable13175(), 2.0)

# issue #13183
gg13183{X}(x::X...) = 1==0 ? gg13183(x, x) : 0
@test gg13183(5) == 0

0 comments on commit 9f72db1

Please sign in to comment.