Skip to content
This repository has been archived by the owner on Jun 4, 2019. It is now read-only.

nfield(x::DataType) #33

Closed
matthieugomez opened this issue May 12, 2017 · 3 comments
Closed

nfield(x::DataType) #33

matthieugomez opened this issue May 12, 2017 · 3 comments

Comments

@matthieugomez
Copy link

matthieugomez commented May 12, 2017

I think that nfield(x::DataType) returns a wrong result on the current master version with Julia 0.6.

using NamedTuples
x = @NT(a = 0.0, b = 0.0, c = 0.0)
nfields(NamedTuples._NT_a_b_c)
# returns 2 while I expected 3

The registered version on Metadata with Julia 0.5 returns 3, which is the answer I expected

@matthieugomez matthieugomez changed the title nfield(type) nfield(x::DataType) May 12, 2017
@shashi
Copy link

shashi commented May 18, 2017

julia> using NamedTuples

julia> x = @NT(a = 0.0, b = 0.0, c = 0.0)
(a = 0.0, b = 0.0, c = 0.0)

julia> nfields(NamedTuples._NT_a_b_c)
2

# however:
julia> nfields(typeof(x))
3

Not sure if this is a bug. cc @JeffBezanson

@JeffBezanson
Copy link
Contributor

Yes, this is not specific to NamedTuples. Currently it's giving 2 since a UnionAll type has 2 components. I'm not sure what to do in this case, but it should be addressed in base julia.

@matthieugomez
Copy link
Author

See discussion in JuliaLang/julia#22350

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants