treturns.nim 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. {.experimental: "strictdefs".}
  2. type Test = object
  3. id: int
  4. proc foo {.noreturn.} = discard
  5. proc test1(): Test =
  6. if true: #[tt.Warning
  7. ^ Cannot prove that 'result' is initialized. This will become a compile time error in the future. [ProveInit]]#
  8. return Test()
  9. else:
  10. return
  11. proc test0(): Test =
  12. if true: #[tt.Warning
  13. ^ Cannot prove that 'result' is initialized. This will become a compile time error in the future. [ProveInit]]#
  14. return
  15. else:
  16. foo()
  17. proc test2(): Test =
  18. if true: #[tt.Warning
  19. ^ Cannot prove that 'result' is initialized. This will become a compile time error in the future. [ProveInit]]#
  20. return
  21. else:
  22. return
  23. proc test3(): Test =
  24. if true: #[tt.Warning
  25. ^ Cannot prove that 'result' is initialized. This will become a compile time error in the future. [ProveInit]]#
  26. return
  27. else:
  28. return Test()
  29. proc test4(): Test =
  30. if true: #[tt.Warning
  31. ^ Cannot prove that 'result' is initialized. This will become a compile time error in the future. [ProveInit]]#
  32. return
  33. else:
  34. result = Test()
  35. return
  36. proc test5(x: bool): Test =
  37. case x: #[tt.Warning
  38. ^ Cannot prove that 'result' is initialized. This will become a compile time error in the future. [ProveInit]]#
  39. of true:
  40. return
  41. else:
  42. return Test()
  43. proc test6(x: bool): Test =
  44. case x: #[tt.Warning
  45. ^ Cannot prove that 'result' is initialized. This will become a compile time error in the future. [ProveInit]]#
  46. of true:
  47. return
  48. else:
  49. return
  50. proc test7(x: bool): Test =
  51. case x: #[tt.Warning
  52. ^ Cannot prove that 'result' is initialized. This will become a compile time error in the future. [ProveInit]]#
  53. of true:
  54. return
  55. else:
  56. discard
  57. proc test8(x: bool): Test =
  58. case x: #[tt.Warning
  59. ^ Cannot prove that 'result' is initialized. This will become a compile time error in the future. [ProveInit]]#
  60. of true:
  61. discard
  62. else:
  63. raise
  64. proc hasImportStmt(): bool =
  65. if false: #[tt.Warning
  66. ^ Cannot prove that 'result' is initialized. This will become a compile time error in the future. [ProveInit]]#
  67. return true
  68. else:
  69. discard
  70. discard hasImportStmt()
  71. block:
  72. proc hasImportStmt(): bool =
  73. if false: #[tt.Warning
  74. ^ Cannot prove that 'result' is initialized. This will become a compile time error in the future. [ProveInit]]#
  75. return true
  76. else:
  77. return
  78. discard hasImportStmt()
  79. block:
  80. block:
  81. proc foo(x: var int) =
  82. discard
  83. proc main =
  84. var s: int
  85. foo(s)#[tt.Warning
  86. ^ use explicit initialization of 's' for clarity [Uninit]]#
  87. main()