t3505.nim 616 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. discard """
  2. cmd: "nim check $options --hints:off $file"
  3. action: "reject"
  4. nimout: '''
  5. t3505.nim(22, 22) Error: cannot assign local to global variable
  6. t3505.nim(31, 28) Error: cannot assign local to global variable
  7. t3505.nim(39, 29) Error: cannot assign local to global variable
  8. '''
  9. """
  10. proc foo =
  11. let a = 0
  12. var b {.global.} = a
  13. foo()
  14. # issue #5132
  15. proc initX(it: float): int = 8
  16. proc initX2(it: int): int = it
  17. proc main() =
  18. var f: float
  19. var x {.global.} = initX2(initX(f))
  20. main()
  21. # issue #20866
  22. proc foo2() =
  23. iterator bar() {.closure.} =
  24. discard
  25. var g {.global.} = rawProc(bar)
  26. foo2()