tvariantasgn.nim 586 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. discard """
  2. output: "came here"
  3. """
  4. #BUG
  5. type
  6. TAnyKind = enum
  7. nkInt,
  8. nkFloat,
  9. nkString
  10. TAny = object
  11. case kind: TAnyKind
  12. of nkInt: intVal: int
  13. of nkFloat: floatVal: float
  14. of nkString: strVal: string
  15. var s: TAny
  16. s = TAny(kind: nkString, strVal: "test")
  17. var nr: TAny
  18. s = TAny(kind: nkInt, intVal: 78)
  19. # s = nr # works
  20. nr = s # fails!
  21. echo "came here"
  22. block: # bug #12464
  23. type
  24. Foo = object
  25. case isFunc: bool
  26. of false: nil
  27. of true:
  28. fun: proc(): int
  29. const i = Foo(isFunc: false)
  30. let j = i
  31. doAssert not j.isFunc