theaproots.nim 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. discard """
  2. action: compile
  3. """
  4. type
  5. Bar = object
  6. x: int
  7. Foo = object
  8. rheap: ref Bar
  9. rmaybe: ref Bar
  10. rstack: ref Bar
  11. list: seq[ref Bar]
  12. listarr: array[0..5, ref Bar]
  13. nestedtup: Tup
  14. inner: TInner
  15. inref: ref TInner
  16. TInner = object
  17. inref: ref Bar
  18. Tup = tuple
  19. tupbar: ref Bar
  20. inner: TInner
  21. proc acc(x: var Foo): var ref Bar =
  22. result = x.rheap
  23. proc test(maybeFoo: var Foo,
  24. maybeSeq: var seq[ref Bar],
  25. bars: var openarray[ref Bar],
  26. maybeTup: var Tup) =
  27. var bb: ref Bar
  28. maybeFoo.rmaybe = bb
  29. maybeFoo.list[3] = bb
  30. maybeFoo.listarr[3] = bb
  31. acc(maybeFoo) = bb
  32. var localFoo: Foo
  33. localFoo.rstack = bb
  34. localFoo.list[3] = bb
  35. localFoo.listarr[3] = bb
  36. acc(localFoo) = bb
  37. var heapFoo: ref Foo
  38. heapFoo.rheap = bb
  39. heapFoo.list[3] = bb
  40. heapFoo.listarr[3] = bb
  41. acc(heapFoo[]) = bb
  42. heapFoo.nestedtup.tupbar = bb
  43. heapFoo.nestedtup.inner.inref = bb
  44. heapFoo.inner.inref = bb
  45. heapFoo.inref.inref = bb
  46. var locseq: seq[ref Bar]
  47. locseq[3] = bb
  48. var locarr: array[0..4, ref Bar]
  49. locarr[3] = bb
  50. maybeSeq[3] = bb
  51. bars[3] = bb
  52. maybeTup[0] = bb
  53. var
  54. ff: ref Foo
  55. tt: Tup
  56. gseq: seq[ref Bar]
  57. new(ff)
  58. test(ff[], gseq, gseq, tt)