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

dangerous type inference failure #3657

Closed
vtjnash opened this issue Jul 9, 2013 · 3 comments
Closed

dangerous type inference failure #3657

vtjnash opened this issue Jul 9, 2013 · 3 comments
Assignees
Labels
kind:bug Indicates an unexpected problem or unintended behavior status:priority This should be addressed urgently
Milestone

Comments

@vtjnash
Copy link
Sponsor Member

vtjnash commented Jul 9, 2013

Start by defining a function for which it is impossible to generate exact information:

julia> function g()
        g(i,2)
       end
# methods for generic function g
g() at none:2

julia> g(::Any,::Int) = 2
# methods for generic function g
g() at none:2
g(::Any,::Int64) at none:1

Looking at the finfer result, we see julia has assumed too much, even though it will call jl_apply_generic and does not know the run-time return type:

julia> finfer(g,())
:($(Expr(:lambda, {}, {{},{},{}}, quote  # none, line 2:
        return g(i,2)::Int64
    end)))

And in fact, we can break it quite easily:

julia> g(::Int,::Int) = 3.0
# methods for generic function g
g() at none:2
g(::Int64,::Int64) at none:1
g(::Any,::Int64) at none:1

julia> finfer(g,())
:($(Expr(:lambda, {}, {{},{},{}}, quote  # none, line 2:
        return g(i,2)::Int64
    end)))

julia> i=1
1

julia> g()
4613937818241073152

julia> reinterpret(Float64, ans)
3.0
@ghost ghost assigned JeffBezanson Jul 9, 2013
@JeffBezanson
Copy link
Sponsor Member

Same issue as #265. Seems bad, but in practice this doesn't come up much.

@vtjnash
Copy link
Sponsor Member Author

vtjnash commented Jul 9, 2013

It seems there should at least be a typeassert in there.

@vtjnash
Copy link
Sponsor Member Author

vtjnash commented Jul 28, 2013

closing, since this is a duplicate

@vtjnash vtjnash closed this as completed Jul 28, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:bug Indicates an unexpected problem or unintended behavior status:priority This should be addressed urgently
Projects
None yet
Development

No branches or pull requests

2 participants