You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would expect this to work but I get an error: Error: undeclared field: 'kind' for type...
# moduleA.nimtypeKinds*=enum A, B, C
Obj*=objectcase kind: Kinds of A: a: stringelse: b: stringprocnewObj*(kind: Kinds): Obj=Obj(kind:kind)
prockind*(o: Obj): Kinds= o.kind
import flatty
import./moduleA
let
a =newObj(B)
serialized =toFlatty(a)
writeFile("tmp.flat", serialized)
let
content =readFile("tmp.flat")
x =fromFlatty(content, Obj)
Making the kind attribute public eliminates the error but I think that should not be necessary. It's also not ideal because then it's possible to change kind which I want to disallow:
# moduleA.nimtypeKinds*=enum A, B, C
Obj*=objectcase kind*: Kinds of A: a: stringelse: b: stringprocnewObj*(kind: Kinds): Obj=Obj(kind:kind)
import flatty
import./moduleA
let
a =newObj(B)
serialized =toFlatty(a)
a.kind = C # Want to disallow thiswriteFile("tmp.flat", serialized)
let
content =readFile("tmp.flat")
x =fromFlatty(content, Obj)
Activity
treeform commentedon May 25, 2026
Thank you for your issue. I have been working on flatty for a bunch of things, and I think I have fixed this in this PR: #52
Feel free to re-open the issue if it still happens to you.