Hi
There seems to be an issue with repr on returned stack objects containing enums. See example below.
If I create the Ret object in local stack frame, it works. If I change Ret.data to uin32 it works even if returned from a function.
type
Status = enum
Ok, Error
Ret = object
status:Status
data:uint8
proc test():Ret =
return Ret(status:Ok,data:0)
let a = test()
echo "a ", a # Ok
echo "a ", repr(a) # Prints "invalid data" for the status field
Same example but with all cases added.
I noticed while working on this example that the issue would disappear and surface again simple by changing the object and function names (no semantic difference). But this version is tested and shows the issue
type
Status = enum
Ok, Error
Ret8 = object
status:Status
data:uint8
Ret32 = object
status:Status
data:uint32
proc test8():Ret8 =
return Ret8(status:Ok,data:0)
proc test32():Ret32 =
return Ret32(status:Ok,data:0)
let local = Ret8(status:Ok,data:0)
echo "local ", repr(local) # Ok
let a = test8()
echo "a ", a # OK
echo "a ", repr(a) # Error
let b = test32()
echo "b ", b # OK
echo "b ", repr(b) # OK