tlent.nim 439 B

12345678910111213141516171819202122232425262728293031323334
  1. discard """
  2. output: '''
  3. hmm
  4. 100
  5. hmm
  6. 100
  7. '''
  8. """
  9. # #16800
  10. type A = object
  11. b: int
  12. var t = A(b: 100)
  13. block:
  14. proc getValues: lent int =
  15. echo "hmm"
  16. result = t.b
  17. echo getValues()
  18. block:
  19. proc getValues: lent int =
  20. echo "hmm"
  21. t.b
  22. echo getValues()
  23. when false: # still an issue, #16908
  24. template main =
  25. iterator fn[T](a:T): lent T = yield a
  26. let a = @[10]
  27. for b in fn(a): echo b
  28. static: main()
  29. main()