Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply type depth limit to :new results #14059

Closed
wants to merge 1 commit into from
Closed
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
2 changes: 1 addition & 1 deletion base/inference.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1078,7 +1078,7 @@ function abstract_eval(e::ANY, vtypes, sv::StaticVarInfo)
elseif is(e.head,:new)
t = abstract_eval(e.args[1], vtypes, sv)
if isType(t)
t = t.parameters[1]
t = limit_type_depth(t.parameters[1], 0, true, Any[])
else
t = Any
end
Expand Down
7 changes: 7 additions & 0 deletions test/core.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3499,3 +3499,10 @@ let
finalize(obj)
@test finalized == 1
end

# non-terminating inference, issue #14009
type A14009{T}
end
A14009{T}(a::T) = A14009{T}()
f14009(a) = ? ? f14009(A14009(a)) : a
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any less confusing way of specifying a condition that type inference cannot reason about?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure, I happen to really like this but I think I'm alone on this one. I somewhat remember convincing Jeff that it made question-mark-as-a-global a feature but maybe he was just being nice.

code_typed(f14009, (Int,))