tlet_uninit3.nim 447 B

12345678910111213141516171819202122232425
  1. discard """
  2. cmd: "nim check $file"
  3. action: "reject"
  4. nimout: '''
  5. tlet_uninit3.nim(13, 5) Error: 'let' symbol requires an initialization
  6. tlet_uninit3.nim(19, 5) Error: 'x' cannot be assigned to
  7. tlet_uninit3.nim(23, 11) Error: 'let' symbol requires an initialization
  8. '''
  9. """
  10. {.experimental: "strictDefs".}
  11. let global {.used.}: int
  12. proc foo() =
  13. block:
  14. let x: int
  15. x = 13
  16. x = 14
  17. block:
  18. let x: int
  19. doAssert x == 0
  20. foo()