JeffreySarnoff/NamedTupleTools.jl

Bug in NamedTuple construction from single element vector of pairs using namedtuple

AzamatB opened this issue · 2 comments

julia> using NamedTupleTools

julia> v = [:a => [1, 2]]
1-element Array{Pair{Symbol,Array{Int64,1}},1}:
 :a => [1, 2]

# construction from collections of names and values works
julia> namedtuple(first.(v), last.(v))
(a = [1, 2],)

# but construction from vector of pairs fails
julia> namedtuple(v)
ERROR: NamedTuple names and field types must have matching lengths
Stacktrace:
 [1] NamedTuple{(:a,),T} where T<:Tuple(::Tuple{Int64,Int64}) at ./boot.jl:547
 [2] NamedTuple{(:a,),T} where T<:Tuple(::Array{Int64,1}) at ./namedtuple.jl:104
 [3] namedtuple(::Array{Pair{Symbol,Array{Int64,1}},1}) at /Users/aberdyshev/.julia/packages/NamedTupleTools/4Qbrj/src/NamedTupleTools.jl:447
 [4] top-level scope at none:1

Thank you for the coverage note. I will add this.

Fix merged in master. Version update pending.