JuliaCollections / JuliaCollections/AbstractTrees.jl
Error in v0.4.3 when building trees over subtypes
Open
Nobody has claimed this yet.
- Dominant language
- Julia
- Stars
- 243
- Forks
- 67
- PR merge metrics
- No merged PRs in 30d
Description
I historically used the following code to build a tree over subtypes. This works in v0.4.2, but fails in v0.4.3.
using AbstractTrees
AbstractTrees.children(t::Type) = subtypes(t)
first(Leaves(Number))
ERROR: MethodError: Cannot `convert` an object of type Tuple{DataType, Int64} to an object of type Nothing
Closest candidates are:
convert(::Type{Nothing}, ::Any) at some.jl:37
convert(::Type{T}, ::Any) where T>:Nothing at some.jl:36
convert(::Type{Nothing}, ::Nothing) at some.jl:38
...
Stacktrace:
[1] convert(#unused#::Type{Nothing}, x::Tuple{DataType, Int64})
@ Base ./some.jl:37
[2] ImplicitCursor(p::ImplicitCursor{DataType, Nothing, Any}, n::Type, s::Tuple{DataType, Int64})
@ AbstractTrees ~/.julia/packages/AbstractTrees/EUx8s/src/cursors.jl:149
[3] iterate(csr::ImplicitCursor{DataType, Nothing, Any}, s::AbstractTrees.InitialState)
@ AbstractTrees ~/.julia/packages/AbstractTrees/EUx8s/src/cursors.jl:174
[4] iterate
@ ~/.julia/packages/AbstractTrees/EUx8s/src/cursors.jl:167 [inlined]
[5] isempty
@ ./essentials.jl:788 [inlined]
[6] descendleft(node::ImplicitCursor{DataType, Nothing, Any})
@ AbstractTrees ~/.julia/packages/AbstractTrees/EUx8s/src/base.jl:176
[7] call_composed
@ ./operators.jl:1039 [inlined]
[8] (::ComposedFunction{ComposedFunction{Type{AbstractTrees.LeavesState}, typeof(descendleft)}, Type{TreeCursor}})(x::Type; kw::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
@ Base ./operators.jl:1035
[9] ComposedFunction
@ ./operators.jl:1033 [inlined]
[10] initial
@ ~/.julia/packages/AbstractTrees/EUx8s/src/iteration.jl:231 [inlined]
[11] iterate(ti::Leaves{DataType})
@ AbstractTrees ~/.julia/packages/AbstractTrees/EUx8s/src/iteration.jl:74
[12] first(itr::Leaves{DataType})
@ Base ./abstractarray.jl:424
[13] top-level scope
@ REPL[8]:1
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Julia reproduction using AbstractTrees.children(t::Type) = subtypes(t) and first(Leaves(Number)). Read src/cursors.jl around ImplicitCursor and iteration, then follow the related calls in src/base.jl and src/iteration.jl. Done means the v0.4.3 failure is resolved and the reproduction works again without the MethodError.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- julia
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100