Skip to content

Functors.children fails on Type in Functors v0.5 #94

@mtfishman

Description

@mtfishman

For example:

julia> using Functors

julia> pkgversion(Functors)
v"0.5.0"

julia> Functors.children(Matrix{Float64})
ERROR: UndefRefError: access to undefined reference
Stacktrace:
 [1] #2
   @ ~/.julia/packages/Functors/1RvWk/src/functor.jl:21 [inlined]
 [2] ntuple(f::Functors.var"#2#5"{DataType, NTuple{8, Symbol}}, n::Int64)
   @ Base ./ntuple.jl:19
 [3] functor(T::Type, x::Type)
   @ Functors ~/.julia/packages/Functors/1RvWk/src/functor.jl:21
 [4] functor(x::Type)
   @ Functors ~/.julia/packages/Functors/1RvWk/src/functor.jl:25
 [5] children(x::Type)
   @ Functors ~/.julia/packages/Functors/1RvWk/src/functor.jl:58
 [6] top-level scope
   @ REPL[11]:1

julia> versioninfo()
Julia Version 1.11.1
Commit 8f5b7ca12ad (2024-10-16 10:53 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: macOS (arm64-apple-darwin22.4.0)
  CPU: 10 × Apple M1 Max
  WORD_SIZE: 64
  LLVM: libLLVM-16.0.6 (ORCJIT, apple-m1)
Threads: 1 default, 0 interactive, 1 GC (on 8 virtual cores)

while:

julia> using Functors

julia> pkgversion(Functors)
v"0.4.12"

julia> Functors.children(Matrix{Float64})
()

The cause seems to be that Functors v0.5 has generic code for walking through structs, which fails for types.

Probably it just requires a definition like:

Functors.functor(x::Type) = NoChildren(), _ -> x

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions