tvararrayiter.nim 393 B

12345678910111213141516171819202122
  1. discard """
  2. targets: "c cpp"
  3. """
  4. block: # issue #24274
  5. iterator foo[T](x: var T): var T =
  6. yield x
  7. var x: array[3, char]
  8. for a in foo(x):
  9. let b = a
  10. var y: array[3, char] = ['a', 'b', 'c']
  11. for a in foo(y):
  12. let b = a
  13. doAssert a[0] == 'a'
  14. doAssert a[1] == 'b'
  15. doAssert a[2] == 'c'
  16. doAssert b[0] == 'a'
  17. doAssert b[1] == 'b'
  18. doAssert b[2] == 'c'