Skip to content

Commit d2b4809

Browse files
committed
Apply type depth limit to :new results
Should fix #14009.
1 parent 4bc24d1 commit d2b4809

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

base/inference.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1078,7 +1078,7 @@ function abstract_eval(e::ANY, vtypes, sv::StaticVarInfo)
10781078
elseif is(e.head,:new)
10791079
t = abstract_eval(e.args[1], vtypes, sv)
10801080
if isType(t)
1081-
t = t.parameters[1]
1081+
t = limit_type_depth(t.parameters[1], 0, true, Any[])
10821082
else
10831083
t = Any
10841084
end

test/core.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3499,3 +3499,10 @@ let
34993499
finalize(obj)
35003500
@test finalized == 1
35013501
end
3502+
3503+
# non-terminating inference, issue #14009
3504+
type A14009{T}
3505+
end
3506+
A14009{T}(a::T) = A14009{T}()
3507+
f14009(a) = ? ? f14009(A14009(a)) : a
3508+
code_typed(f14009, (Int,))

0 commit comments

Comments
 (0)