-
Notifications
You must be signed in to change notification settings - Fork 21
Closed
Description
Hi, I'm getting this error trying to convert a NamedTuple to store in a NamedTuple field:
ERROR: ArgumentError: type does not have a definite number of fields
Stacktrace:
[1] fieldcount(t::Any)
@ Base ./reflection.jl:729
[2] construct
@ ~/.julia/packages/StructTypes/Cmlkm/src/StructTypes.jl:573 [inlined]
[3] constructfrom(#unused#::StructTypes.UnorderedStruct, #unused#::Type{NamedTuple}, #unused#::StructTypes.UnorderedStruct, obj::NamedTuple{(), Tuple{}})
@ StructTypes ~/.julia/packages/StructTypes/Cmlkm/src/StructTypes.jl:1046
[4] constructfrom
@ ~/.julia/packages/StructTypes/Cmlkm/src/StructTypes.jl:1018 [inlined]
[5] constructfrom(#unused#::Type{NamedTuple}, obj::NamedTuple{(), Tuple{}})
@ StructTypes ~/.julia/packages/StructTypes/Cmlkm/src/StructTypes.jl:905
[6] StructClosure
@ ~/.julia/packages/StructTypes/Cmlkm/src/StructTypes.jl:1041 [inlined]
I made some definitions that seem to fix it, what do you think (seems like both Struct and UnorderedStruct are needed)?
constructfrom(::Struct, ::Type{ST}, ::Struct, obj::OT) where {ST <: NamedTuple, OT <: ST} = obj
constructfrom(::UnorderedStruct, ::Type{ST}, ::UnorderedStruct, obj::OT) where {ST <: NamedTuple, OT <: ST} = objMetadata
Metadata
Assignees
Labels
No labels