diff options
author | Oscar NihlgÄrd <oscarnihlgard@gmail.com> | 2019-10-24 11:04:04 +0200 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2019-10-24 11:04:04 +0200 |
commit | 9ccfcf5dd2572c858913cf092a6a571a5e4a8df0 (patch) | |
tree | 43c76d728596a0f8f847a3fe6be0140562cfd6e9 | |
parent | 822078ed12a48aa61eda0c65bc9ee675836a9fd3 (diff) | |
download | Nim-9ccfcf5dd2572c858913cf092a6a571a5e4a8df0.tar.gz |
Fix compiler crash caused by top level return (#12501)
-rw-r--r-- | compiler/semexprs.nim | 2 | ||||
-rw-r--r-- | tests/misc/t12480.nim | 5 |
2 files changed, 6 insertions, 1 deletions
diff --git a/compiler/semexprs.nim b/compiler/semexprs.nim index ed38f66e1..2e9c5e1f5 100644 --- a/compiler/semexprs.nim +++ b/compiler/semexprs.nim @@ -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: diff --git a/tests/misc/t12480.nim b/tests/misc/t12480.nim new file mode 100644 index 000000000..992533ef6 --- /dev/null +++ b/tests/misc/t12480.nim @@ -0,0 +1,5 @@ +discard """ + errormsg: "'return' not allowed here" +""" + +return \ No newline at end of file |