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

Avoid infinite type recursion in type inference #14009

Closed
yuyichao opened this issue Nov 15, 2015 · 0 comments
Closed

Avoid infinite type recursion in type inference #14009

yuyichao opened this issue Nov 15, 2015 · 0 comments
Labels
types and dispatch Types, subtyping and method dispatch

Comments

@yuyichao
Copy link
Contributor

See point 2 in JuliaLang/LinearAlgebra.jl#283

A minimum repro is,

type A{T}
end

A{T}(a::T) = A{T}()

function f(a)
    if rand() > 100
        return f(A(a))
    end
end

@code_warntype f(1)

Even though the recursion path will never be executed, type inference will still try to infer the type of the recursion call with a infinitely deep type and even if there's a genuine infinite recursion, it's better to do that at runtime and not in type inference.....

We already have a bunch of limit on type length so I think we should probably also have some limit here.

@carnaval Does green-fairy provide any general solution to these problems?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
types and dispatch Types, subtyping and method dispatch
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant