Hi, i tried create an object that has object variants using `alloc(size:
Natural)` but when assigning the variant kind it throws an exception, is there
a way for assign it without creating an auxiliar object or without using
`-d:nimOldCaseObjects`?, here is a example:
type
Kinds = enum
kA, kB, kC
ExampleBlock = object
case kind: Kinds
of kA: a: int
of kB: b: string
of kC: c: uint16
otherFields: array[16, int]
when isMainModule:
echo "Sizeof block, ", sizeof(ExampleBlock) # Is a union after all
let kindcrash = cast[ptr ExampleBlock](
alloc0(sizeof(ExampleBlock))
)
kindcrash.kind = kB # Crash Here
kindcrash.b = "String Test"
echo kindcrash.b
Run