tvariantasgn.nim 408 B

12345678910111213141516171819202122232425262728293031
  1. discard """
  2. file: "tvariantasgn.nim"
  3. output: "came here"
  4. """
  5. #BUG
  6. type
  7. TAnyKind = enum
  8. nkInt,
  9. nkFloat,
  10. nkString
  11. TAny = object
  12. case kind: TAnyKind
  13. of nkInt: intVal: int
  14. of nkFloat: floatVal: float
  15. of nkString: strVal: string
  16. var s: TAny
  17. s.kind = nkString
  18. s.strVal = "test"
  19. var nr: TAny
  20. nr.kind = nkint
  21. nr.intVal = 78
  22. # s = nr # works
  23. nr = s # fails!
  24. echo "came here"