t20152.nim 402 B

123456789101112131415161718192021
  1. discard """
  2. action: compile
  3. """
  4. proc foo() =
  5. iterator it():int {.closure.} =
  6. yield 1
  7. proc useIter() {.nimcall.} =
  8. var iii = it # <-- illegal capture
  9. doAssert iii() == 1
  10. useIter()
  11. foo()
  12. proc foo2() =
  13. proc bar() = # Local function, but not a closure, because no captures
  14. echo "hi"
  15. proc baz() {.nimcall.} = # Calls local function
  16. bar()
  17. baz()
  18. foo2()