`nfields` giving incorrect number of fields

The following seems like a bug to me.

julia> struct MyType
           a
           b
           c
           d
           e
           f
           g
           h
           i
           j
           k
           l
           m
           n
           o
           p
           q
           r
           s
           t
           u
           v
           w
           x
           y
           z
       end

julia> nfields(MyType)
20

julia> length(fieldnames(MyType))
26

Ahhh, I think I got it. It actually counts the fields of the DataType object MyType. There, 20 is correct.

https://github.com/JuliaLang/julia/issues/29977

3 Likes

Ok, so fieldcount(MyType) gives me what I want. Somewhat confusing indeed.