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

Fails to descend into Type constructors #42

Closed
mbauman opened this issue Jun 18, 2019 · 3 comments · Fixed by #43
Closed

Fails to descend into Type constructors #42

mbauman opened this issue Jun 18, 2019 · 3 comments · Fixed by #43

Comments

@mbauman
Copy link

mbauman commented Jun 18, 2019

For example:

julia> @descend Array{Int}(undef, 2)
ERROR: MethodError: no method matching _descend(::Nothing; params=Core.Compiler.Params(Core.Compiler.InferenceResult[], 0x0000000000006741, true, true, true, false, 100, 1000, 400, 4, 4, 8, 3, 32), iswarn=false)
Closest candidates are:
  _descend(::Any, ::Any; params, kwargs...) at /home/mbauman/.julia/packages/Cthulhu/c2nCD/src/Cthulhu.jl:202
  _descend(::Core.MethodInstance; iswarn, params, optimize, kwargs...) at /home/mbauman/.julia/packages/Cthulhu/c2nCD/src/Cthulhu.jl:112
Stacktrace:
 [1] #_descend#37(::Core.Compiler.Params, ::Base.Iterators.Pairs{Symbol,Bool,Tuple{Symbol},NamedTuple{(:iswarn,),Tuple{Bool}}}, ::typeof(Cthulhu._descend), ::Any, ::Any) at /home/mbauman/.julia/packages/Cthulhu/c2nCD/src/Cthulhu.jl:203
 [2] #_descend at ./none:0 [inlined]
 [3] #_descend_with_error_handling#31(::Base.Iterators.Pairs{Symbol,Bool,Tuple{Symbol},NamedTuple{(:iswarn,),Tuple{Bool}}}, ::typeof(Cthulhu._descend_with_error_handling), ::Type, ::Any) at /home/mbauman/.julia/packages/Cthulhu/c2nCD/src/Cthulhu.jl:88
 [4] #_descend_with_error_handling at ./none:0 [inlined]
 [5] #descend_code_typed#30 at /home/mbauman/.julia/packages/Cthulhu/c2nCD/src/Cthulhu.jl:62 [inlined]
 [6] descend_code_typed(::Type, ::Any) at /home/mbauman/.julia/packages/Cthulhu/c2nCD/src/Cthulhu.jl:62
 [7] top-level scope at REPL[32]:1

Of course this example wouldn't be terribly interesting, but this came from a different example where the constructor was actually doing something I wanted to look at.

@vchuravy
Copy link
Member

Interesting.

julia> Base._methods_by_ftype(Tuple{Array{Int}, typeof(undef), Int}, -1, typemax(UInt))
0-element Array{Any,1}
julia> code_typed(Array{Int}, (typeof(undef), Int))
1-element Array{Any,1}:
 CodeInfo(
1 ─ %1 = $(Expr(:foreigncall, :(:jl_alloc_array_1d), Array{Int64,1}, svec(Any, Int64), :(:ccall), 2, Array{Int64,1}, :(m), :(m)))::Array{Int64,1}
└──      return %1
) => Array{Int64,1}

The former method is what Cthulhu uses.

@vchuravy
Copy link
Member

Ah:

Base._methods(Array{Int}, Tuple{typeof(undef), Int}, -1, typemax(UInt))
1-element Array{Any,1}:
 svec(Tuple{Type{Array{Int64,N} where N},UndefInitializer,Int64}, svec(Int64), (::Type{Array{T,N} where N})(::UndefInitializer, m::Int64) where T in Core at boot.jl:416)

@mbauman
Copy link
Author

mbauman commented Jun 19, 2019

Thanks!

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

Successfully merging a pull request may close this issue.

2 participants