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

return_types errors with: _nref has no method matching _nref(::Type{N}, ::Symbol, ::Expr) #9135

Closed
mauro3 opened this issue Nov 24, 2014 · 5 comments

Comments

@mauro3
Copy link
Contributor

mauro3 commented Nov 24, 2014

I get these errors after updating my julia master:

   _       _ _(_)_     |  A fresh approach to technical computing
  (_)     | (_) (_)    |  Documentation: http://docs.julialang.org
   _ _   _| |_  __ _   |  Type "help()" for help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 0.4.0-dev+1783 (2014-11-24 06:06 UTC)
 _/ |\__'_|_|_|\__'_|  |  Commit 3ccaf3c* (0 days old master)
|__/                   |  x86_64-unknown-linux-gnu

julia> Base.return_types(getindex, (Array{Int64,2}, Any))
ERROR: `_nref` has no method matching _nref(::Type{N}, ::Symbol, ::Expr)
 in func_for_method at ./inference.jl:602
 in return_types at inference.jl:3072

julia> Base.return_types(setindex!, (Array{Int64,2}, Any, Base.IteratorsMD.CartesianIndex))
ERROR: `_nref` has no method matching _nref(::Type{N}, ::Symbol, ::Expr)
 in func_for_method at ./inference.jl:602
 in return_types at inference.jl:3072

julia> Base.return_types(getindex, (Array{Int64,2}, Base.IteratorsMD.CartesianIndex))
ERROR: `_nref` has no method matching _nref(::Type{N}, ::Symbol, ::Expr)
 in func_for_method at ./inference.jl:602
 in return_types at inference.jl:3072

Might be this: 81136af

@timholy
Copy link
Member

timholy commented Nov 24, 2014

This specific error is, once again, #8504. However, even if we apply #8973, this still gives an error:

julia> Base.return_types(getindex, (Array{Int64,2}, Any))
ERROR: `anonymous` has no method matching anonymous(::Type{Array{Int64,2}}, ::Type{Any})
 in func_for_method at ./inference.jl:602
 in return_types at inference.jl:3077

Perhaps we need a try/catch block in that loop in Base.return_types?

mauro3 added a commit to mauro3/Traits.jl that referenced this issue Nov 24, 2014
troubles.  This is a workaround, undo once the issue is fixed.
@timholy
Copy link
Member

timholy commented Nov 24, 2014

More info:

julia> Base.return_types(getindex, (Array{Int64,2}, Base.IteratorsMD.CartesianIndex{2}))
1-element Array{Any,1}:                                                                                                                                                                                                                                                        
 Union(Int64,Array{T,N})                                                                                                                                                                                                                                                       

julia> Base.return_types(getindex, (Array{Int64,2}, Base.IteratorsMD.CartesianIndex_2))
ERROR: CartesianIndex_2 not defined                                                                                                                                                                                                                                            

julia> Base.IteratorsMD.gen_cartesian(2)
(:CartesianIndex_2,:IndexIterator_2)                                                                                                                                                                                                                                           

julia> Base.return_types(getindex, (Array{Int64,2}, Base.IteratorsMD.CartesianIndex_2))
1-element Array{Any,1}:
 Int64

@mauro3
Copy link
Contributor Author

mauro3 commented Mar 26, 2015

Issue #8504 is now fixed but this still does not work. However, the errors changed, probably due to #10178:

  _       _ _(_)_     |  A fresh approach to technical computing
  (_)     | (_) (_)    |  Documentation: http://docs.julialang.org
   _ _   _| |_  __ _   |  Type "help()" for help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 0.4.0-dev+4022 (2015-03-26 19:08 UTC)
 _/ |\__'_|_|_|\__'_|  |  Commit 01a3216* (0 days old master)
|__/                   |  x86_64-unknown-linux-gnu

julia> Base.return_types(getindex, (Array{Int64,2}, Any))
ERROR: 
 in return_types at inference.jl:3364

monkey-patching as suggested by @Jutho in #10178 gives a similar error to when I first reported this:

   _       _ _(_)_     |  A fresh approach to technical computing
  (_)     | (_) (_)    |  Documentation: http://docs.julialang.org
   _ _   _| |_  __ _   |  Type "help()" for help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 0.4.0-dev+4022 (2015-03-26 19:08 UTC)
 _/ |\__'_|_|_|\__'_|  |  Commit 01a3216* (0 days old master)
|__/                   |  x86_64-unknown-linux-gnu

julia> function Base.func_for_method(m::Method, tt, env)
           if !m.isstaged
               return m.func.code
           else
               f=ccall(:jl_instantiate_staged,Any,(Any,Any,Any),m,tt,env)
               return f.code
           end
       end
Warning: Method definition func_for_method(Method,Any,Any) in module Base at inference.jl:666 overwritten in module Main at none:2.
func_for_method (generic function with 1 method)

julia> Base.return_types(getindex, (Array{Int64,2}, Any))
ERROR: MethodError: `_ncall` has no method matching _ncall(::Type{N}, ::Expr, ::Symbol, ::Expr)
Closest candidates are:
  _ncall(::Int64, ::Any, ::Any...)
 in func_for_method at none:5
 in return_types at inference.jl:3364

Any change of a fix with #8504 in place?

@timholy
Copy link
Member

timholy commented Mar 26, 2015

There's #9139, but I'm not sure if it's a good idea.

@JeffBezanson
Copy link
Member

The behavior

julia> Base.return_types(getindex, (Array{Int64,2}, Any))
ERROR: 
 in return_types at inference.jl:3364

is expected, since we can only call staged functions on concrete types. An error message was left out since this was intended only for internal consumption. We can add a message. Look for error() in inference.jl.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants