Skip to content

Commit

Permalink
Fix semantic analysis with noReturn proc in tail pos (nim-lang#10422)
Browse files Browse the repository at this point in the history
  • Loading branch information
LemonBoy authored and ThomasTJdev committed Jan 27, 2019
1 parent 35fa293 commit 0b378a6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
3 changes: 2 additions & 1 deletion compiler/semstmts.nim
Expand Up @@ -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 =
Expand Down
10 changes: 10 additions & 0 deletions tests/exception/texceptions.nim
Expand Up @@ -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)

0 comments on commit 0b378a6

Please sign in to comment.