I am trying to implement the famous Lox language based on Robert Nystrom's book, but in Crystal. Now I stumbled upon the following flaw/error:
I have an enum for OpCodes, with type UInt8:
enum OpCode : UInt8
OP_RETURN = 1
end
and an array of UInt8's
@code = Pointer(UInt8).malloc( 8 )
But now when I want to assign code[0] = OP_RETURN, even with all possible type conversions I still get the following error message:
Error: can't cast OpCode to UInt8
But I thought OpCode WAS UInt8 as declared.
Any ideas? Really appreciated. I'm just in the baby steps of learning Crystal but so far I'm impressed by this language but there are edge corners where one just needs help.