quinnj / JSON3.jl

Other
214 stars 47 forks source link

invalid builtin function call: Base.getfield(t::NamedTuple{(), Tuple{}}, i::Symbol) #249

Open lgeissbauer-btig opened 1 year ago

lgeissbauer-btig commented 1 year ago

I'll just post the code and the versions. Just ask if there are questions

Julia v"1.8.4" (and current nightly) JET v0.6.21

julia> using Dates

julia> struct Data
           Command::String
           Time::Union{DateTime, Nothing}
           Sender_ID::Int64

           Payload::Union{
               Dict{String, Union{String, Nothing}},
               Nothing
           }
       end

julia> using StructTypes

julia> StructTypes.StructType(::Type{Data}) = StructTypes.Struct()

julia> using JSON3

julia> using JET

julia> JET.@report_call JSON3.read("", Data)
═════ 2 possible errors found ═════
┌ @ C:\.julia\packages\JSON3\CpNms\src\structs.jl:32 JSON3.:(var"#read#16")(false, pairs(NamedTuple()), #self#, str, _3)
│┌ @ C:\.julia\packages\JSON3\CpNms\src\structs.jl:40  = JSON3.read(JSON3.StructType(T), buf, pos, len, b, T)
││┌ @ C:\.julia\packages\JSON3\CpNms\src\structs.jl:566 JSON3.:(var"#read#50")(pairs(NamedTuple()), #self#, _2, buf, pos, len, b, _7)
│││┌ @ C:\.julia\packages\JSON3\CpNms\src\structs.jl:617 JSON3.StructTypes.applyfield(c, T, key)
││││┌ @ C:\.julia\packages\StructTypes\AK4aM\src\StructTypes.jl:891 StructTypes.defaults(T)[nm]
│││││┌ @ namedtuple.jl:137 Base.getfield(t, i)
││││││ invalid builtin function call: Base.getfield(t::NamedTuple{(), Tuple{}}, i::Symbol)
│││││└─────────────────────
│││┌ @ C:\.julia\packages\JSON3\CpNms\src\structs.jl:620 JSON3.read(JSON3.Struct(), buf, pos, len, b, JSON3.Any)
││││┌ @ C:\.julia\packages\JSON3\CpNms\src\structs.jl:97 JSON3.:(var"#read#25")(false, pairs(NamedTuple()), #self#, _2, buf, pos, len, b, _7)
│││││┌ @ C:\.julia\packages\JSON3\CpNms\src\structs.jl:352 JSON3.:(var"#read#43")(kw..., _3, _4, buf, pos, len, b, _9, _10, _11)
││││││┌ @ C:\.julia\packages\JSON3\CpNms\src\structs.jl:404  = Core.kwfunc(JSON3.read)(merge(Base.NamedTuple(), kw), JSON3.read, JSON3.StructType(V), buf, pos, len, b, V)
│││││││┌ @ C:\.julia\packages\JSON3\CpNms\src\structs.jl:97 JSON3.:(var"#read#25")(allow_inf, kw..., _3, _4, buf, pos, len, b, _9)
││││││││┌ @ C:\.julia\packages\JSON3\CpNms\src\structs.jl:97 JSON3.:(var"#read#25")(false, pairs(NamedTuple()), #self#, _2, buf, pos, len, b, _7)
│││││││││┌ @ C:\.julia\packages\JSON3\CpNms\src\structs.jl:101 Core.kwfunc(JSON3.read)(merge(NamedTuple{(:allow_inf,)}(tuple(allow_inf)), kw), JSON3.read, JSON3.ArrayType(), buf, pos, len, b, Array{Any})
││││││││││┌ @ C:\.julia\packages\JSON3\CpNms\src\structs.jl:209 JSON3.:(var"#read#30")(kw..., _3, _4, buf, pos, len, b, _9)
│││││││││││┌ @ C:\.julia\packages\JSON3\CpNms\src\structs.jl:209 JSON3.read(JSON3.ArrayType(), buf, pos, len, b, T, _10)
││││││││││││┌ @ C:\.julia\packages\JSON3\CpNms\src\structs.jl:322 JSON3.:(var"#read#37")(pairs(NamedTuple()), #self#, _2, buf, pos, len, b, _7, _8)
│││││││││││││┌ @ C:\.julia\packages\JSON3\CpNms\src\structs.jl:336 x = JSON3.StructTypes.construct(c, T)
││││││││││││││┌ @ C:\.julia\packages\StructTypes\AK4aM\src\StructTypes.jl:630 kwargs[k_i]
│││││││││││││││┌ @ namedtuple.jl:136 Base.getfield(t, i)
││││││││││││││││ invalid builtin function call: Base.getfield(t::NamedTuple{(), Tuple{}}, i::Int64)
│││││││││││││││└─────────────────────

https://github.com/aviatesk/JET.jl/issues/448