tcompiles.nim 910 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. discard """
  2. matrix: "--warningAsError:ProveInit --warningAsError:Uninit"
  3. """
  4. {.experimental: "strictdefs".}
  5. type Test = object
  6. id: int
  7. proc foo {.noreturn.} = discard
  8. block:
  9. proc test(x: bool): Test =
  10. if x:
  11. foo()
  12. else:
  13. foo()
  14. block:
  15. proc test(x: bool): Test =
  16. if x:
  17. result = Test()
  18. else:
  19. foo()
  20. discard test(true)
  21. block:
  22. proc test(x: bool): Test =
  23. if x:
  24. result = Test()
  25. else:
  26. return Test()
  27. discard test(true)
  28. block:
  29. proc test(x: bool): Test =
  30. if x:
  31. return Test()
  32. else:
  33. return Test()
  34. discard test(true)
  35. block:
  36. proc test(x: bool): Test =
  37. if x:
  38. result = Test()
  39. else:
  40. result = Test()
  41. return
  42. discard test(true)
  43. block:
  44. proc test(x: bool): Test =
  45. if x:
  46. result = Test()
  47. return
  48. else:
  49. raise newException(ValueError, "unreachable")
  50. discard test(true)