diff options
Diffstat (limited to 'tests/init/tcompiles.nim')
-rw-r--r-- | tests/init/tcompiles.nim | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/tests/init/tcompiles.nim b/tests/init/tcompiles.nim new file mode 100644 index 000000000..2072702ad --- /dev/null +++ b/tests/init/tcompiles.nim @@ -0,0 +1,64 @@ +discard """ + matrix: "--warningAsError:ProveInit --warningAsError:Uninit" +""" + +{.experimental: "strictdefs".} + +type Test = object + id: int + +proc foo {.noreturn.} = discard + +block: + proc test(x: bool): Test = + if x: + foo() + else: + foo() + +block: + proc test(x: bool): Test = + if x: + result = Test() + else: + foo() + + discard test(true) + +block: + proc test(x: bool): Test = + if x: + result = Test() + else: + return Test() + + discard test(true) + +block: + proc test(x: bool): Test = + if x: + return Test() + else: + return Test() + + discard test(true) + +block: + proc test(x: bool): Test = + if x: + result = Test() + else: + result = Test() + return + + discard test(true) + +block: + proc test(x: bool): Test = + if x: + result = Test() + return + else: + raise newException(ValueError, "unreachable") + + discard test(true) |