fixes #9839; fixes noReturn pragma doesn't work for non-simple templates (#21048)

This commit is contained in:
ringabout
2022-12-08 17:37:02 +08:00
committed by GitHub
parent 4480fd3e93
commit c5eb3fd4f0
2 changed files with 38 additions and 3 deletions

View File

@@ -0,0 +1,32 @@
discard """
cmd: "nim check --warningAsError:UnreachableCode $file"
action: "reject"
nimout: '''
tunreachable.nim(23, 3) Error: unreachable code after 'return' statement or '{.noReturn.}' proc [UnreachableCode]
tunreachable.nim(30, 3) Error: unreachable code after 'return' statement or '{.noReturn.}' proc [UnreachableCode]
'''
"""
# bug #9839
template myquit1():untyped=
## foo
quit(1)
template myquit2():untyped=
echo 123
myquit1()
proc main1()=
# BUG: uncommenting this doesn't give `Error: unreachable statement`
myquit2()
echo "after"
main1()
proc main2() =
myquit1()
echo "after"
main2()