JuliaData / StructTypes.jl

Abstract definitions and convenience methods for describing, processing, and constructing Julia objects
https://juliadata.github.io/StructTypes.jl/stable/
MIT License
80 stars 22 forks source link

Error after v1.7 update #47

Closed felipenoris closed 3 years ago

felipenoris commented 3 years ago

I'm getting the following error after updating to StructTypes.jl 1.7.

I'll try to isolate the error with a code example.

LoadError: LoadError: MethodError: construct(::Type{Nothing}, ::Nothing) is ambiguous. Candidates:                                       
  construct(T, ::Nothing; kw...) in StructTypes at /rhome/FNORO/.julia/packages/StructTypes/frYBf/src/StructTypes.jl:504                        
  construct(::Type{T}, x::T; kw...) where T in StructTypes at /rhome/FNORO/.julia/packages/StructTypes/frYBf/src/StructTypes.jl:311             
Possible fix, define                                                                                                                            
  construct(::Type{Nothing}, ::Nothing)                                                                                                         
Stacktrace:                                                                                                                                     
  [1] read(::StructTypes.NullType, buf::Base.CodeUnits{UInt8, String}, pos::Int64, len::Int64, b::UInt8, ::Type{Nothing}; kw::Base.Iterators.Pai
rs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})                                                                                         
    @ JSON3 ~/.julia/packages/JSON3/czMzK/src/structs.jl:154                                                                                    
  [2] read(::StructTypes.NullType, buf::Base.CodeUnits{UInt8, String}, pos::Int64, len::Int64, b::UInt8, ::Type{Nothing})                       
    @ JSON3 ~/.julia/packages/JSON3/czMzK/src/structs.jl:149                                                                                    
  [3] read(::StructTypes.UnorderedStruct, buf::Base.CodeUnits{UInt8, String}, pos::Int64, len::Int64, b::UInt8, ::Type{Any}; allow_inf::Bool, kw
::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})                                                                     
    @ JSON3 ~/.julia/packages/JSON3/czMzK/src/structs.jl:78                                                                                     
  [4] read                                                                                                                                      
    @ ~/.julia/packages/JSON3/czMzK/src/structs.jl:71 [inlined]                                                                                 
  [5] pretty(out::IOBuffer, str::String, indent::Int64, offset::Int64; kw::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{
}}})                                                                                                                                            
    @ JSON3 ~/.julia/packages/JSON3/czMzK/src/pretty.jl:42
quinnj commented 3 years ago

Ah shoot. Let me see if there's an easy fix.

quinnj commented 3 years ago

Can you try https://github.com/JuliaData/StructTypes.jl/pull/49 to see if that fixes it?

felipenoris commented 3 years ago

@quinnj yes the fix solves the issue. Many thanks!