proc len(t: tuple|object): int =
      for _ in fields(t):
        inc len
    

Should this be
    
    
    proc len(t: tuple|object): int =
      for _ in fields(t):
        inc result
    

Fieldnames still doesn't compile for me as written but len returns 3 with this 
change. Before changing, the compiler was trying to increment the len proc, 
reporting:

_Error: type mismatch: got (proc (t: tuple or object): int | proc (w: 
WideCString): int{.noSideEffect, gcsafe, locks: 0.} | proc (x: TOpenArray): 
int{.noSideEffect.} | proc (x: string): int{.noSideEffect.} | proc (x: seq[T]): 
int{.noSideEffect.} | proc (x: array[I, T]): int{.noSideEffect.} | proc (x: 
cstring): int{.noSideEffect.})_

_but expected one of:_

_proc inc[T: Ordinal | uint | uint64](x: var T; y = 1)_

Reply via email to