mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-22 04:20:44 +00:00
Fix compiler crash caused by top level return (#12501)
This commit is contained in:
committed by
Andreas Rumpf
parent
822078ed12
commit
9ccfcf5dd2
@@ -1724,7 +1724,7 @@ proc semReturn(c: PContext, n: PNode): PNode =
|
||||
result = n
|
||||
checkSonsLen(n, 1, c.config)
|
||||
if c.p.owner.kind in {skConverter, skMethod, skProc, skFunc, skMacro} or
|
||||
isClosureIterator(c.p.owner.typ):
|
||||
(not c.p.owner.typ.isNil and isClosureIterator(c.p.owner.typ)):
|
||||
if n.sons[0].kind != nkEmpty:
|
||||
# transform ``return expr`` to ``result = expr; return``
|
||||
if c.p.resultSym != nil:
|
||||
|
||||
5
tests/misc/t12480.nim
Normal file
5
tests/misc/t12480.nim
Normal file
@@ -0,0 +1,5 @@
|
||||
discard """
|
||||
errormsg: "'return' not allowed here"
|
||||
"""
|
||||
|
||||
return
|
||||
Reference in New Issue
Block a user