diff options
author | ringabout <43030857+ringabout@users.noreply.github.com> | 2023-09-18 14:28:40 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-18 08:28:40 +0200 |
commit | deefbc420e218459ffc6ccf915f625cd48e083b4 (patch) | |
tree | c205895f0ee2a0b1e6e5eaacaa50f6005fd8b594 /tests | |
parent | bd857151d827c732f882c1fef52b91b5582ed65c (diff) | |
download | Nim-deefbc420e218459ffc6ccf915f625cd48e083b4.tar.gz |
fixes `result` requires explicit initialization on noReturn code (#22717)
fixes #21615; fixes #16735 It also partially fixes | #22673, though It still gives 'baseless' warnings.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/init/tcompiles.nim | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/init/tcompiles.nim b/tests/init/tcompiles.nim index 2072702ad..e86cad1e2 100644 --- a/tests/init/tcompiles.nim +++ b/tests/init/tcompiles.nim @@ -62,3 +62,30 @@ block: raise newException(ValueError, "unreachable") discard test(true) + +# bug #21615 +# bug #16735 + +block: + type Test {.requiresInit.} = object + id: int + + proc bar(): int = + raise newException(CatchableError, "error") + + proc test(): Test = + raise newException(CatchableError, "") + + template catchError(body) = + var done = false + try: + body + except CatchableError: + done = true + doAssert done + + catchError: + echo test() + + catchError: + echo bar() |