diff options
author | LemonBoy <LemonBoy@users.noreply.github.com> | 2019-01-23 07:30:49 +0100 |
---|---|---|
committer | Miran <narimiran@disroot.org> | 2019-01-23 07:30:49 +0100 |
commit | eee9729f536fecd94565e879f28edcb73bcf3861 (patch) | |
tree | dcef2e0831c272ac544fb8ec802df366c54716f3 | |
parent | 94f6a6b29447caa1814016c61f9dd30b82d83eab (diff) | |
download | Nim-eee9729f536fecd94565e879f28edcb73bcf3861.tar.gz |
Fix semantic analysis with noReturn proc in tail pos (#10422)
Fixes #10417
-rw-r--r-- | compiler/semstmts.nim | 3 | ||||
-rw-r--r-- | tests/exception/texceptions.nim | 10 |
2 files changed, 12 insertions, 1 deletions
diff --git a/compiler/semstmts.nim b/compiler/semstmts.nim index 17f88d039..cac24d33e 100644 --- a/compiler/semstmts.nim +++ b/compiler/semstmts.nim @@ -279,7 +279,8 @@ proc semTry(c: PContext, n: PNode; flags: TExprFlags): PNode = for i in 1..last: var it = n.sons[i] let j = it.len-1 - it.sons[j] = fitNode(c, typ, it.sons[j], it.sons[j].info) + if not endsInNoReturn(it.sons[j]): + it.sons[j] = fitNode(c, typ, it.sons[j], it.sons[j].info) result.typ = typ proc fitRemoveHiddenConv(c: PContext, typ: PType, n: PNode): PNode = diff --git a/tests/exception/texceptions.nim b/tests/exception/texceptions.nim index b30b3874b..d63187b0e 100644 --- a/tests/exception/texceptions.nim +++ b/tests/exception/texceptions.nim @@ -64,3 +64,13 @@ proc return_in_except = try: return_in_except() except: echo "RECOVER" +block: #10417 + proc moo() {.noreturn.} = discard + + let bar = + try: + 1 + except: + moo() + + doAssert(bar == 1) |