type
      Enum1* {.size: sizeof(cint), pure.} = enum
        p1 = cint(1), p2 = cint(2)
    
    proc `xor`*(x, y: Enum1): Enum1 =
      cast[Enum1](cast[cint](x) xor cast[cint](y))
    
    let a = Enum1.p1 xor Enum1.p2 # this works
    
    type Enum2* {.size: sizeof(cint), pure.} = enum
      p1 = cint(8),
      p2 = Enum1.p1 xor Enum1.p2 # main.nim(6, 3) Error: VM is only allowed to 
'cast' between integers of same size
    
    
    Run

It's very hard to port C and C++ enums to Nim with this error.

Reply via email to