tmisc_issues.nim 551 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. discard """
  2. matrix: "--mm:refc; --mm:orc"
  3. targets: "c cpp js"
  4. """
  5. import std/assertions
  6. # bug #20227
  7. type
  8. Data = object
  9. id: int
  10. Test = distinct Data
  11. Object = object
  12. data: Test
  13. var x: Object = Object(data: Test(Data(id: 12)))
  14. doAssert Data(x.data).id == 12
  15. block: # bug #16771
  16. type A = object
  17. n: int
  18. proc foo(a, b: var A) =
  19. swap a, b
  20. var a, b: A
  21. a.n = 42
  22. b.n = 1
  23. doAssert a.n == 42
  24. doAssert b.n == 1
  25. a.swap b
  26. doAssert a.n == 1
  27. doAssert b.n == 42
  28. a.foo b
  29. doAssert a.n == 42
  30. doAssert b.n == 1