tlet.nim 808 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. {.experimental: "strictDefs".}
  2. proc bar(x: out string) =
  3. x = "abc"
  4. template moe = # bug #21043
  5. try:
  6. discard
  7. except ValueError as e:
  8. echo(e.msg)
  9. template moe0 {.dirty.} = # bug #21043
  10. try:
  11. discard
  12. except ValueError as e:
  13. echo(e.msg)
  14. proc foo() =
  15. block:
  16. let x: string
  17. if true:
  18. x = "abc"
  19. else:
  20. x = "def"
  21. doAssert x == "abc"
  22. block:
  23. let y: string
  24. bar(y)
  25. doAssert y == "abc"
  26. block:
  27. let x: string
  28. if true:
  29. x = "abc"
  30. discard "abc"
  31. else:
  32. x = "def"
  33. discard "def"
  34. doAssert x == "abc"
  35. block: #
  36. let x {.used.} : int
  37. block: #
  38. let x: float
  39. x = 1.234
  40. doAssert x == 1.234
  41. block:
  42. try:
  43. discard
  44. except ValueError as e:
  45. echo(e.msg)
  46. moe()
  47. moe0()
  48. static: foo()
  49. foo()