diff options
author | Araq <rumpf_a@web.de> | 2014-09-11 00:45:29 +0200 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2014-09-11 00:45:29 +0200 |
commit | b7f8dbbec2bc01f753100659f3db35b024e0076a (patch) | |
tree | 3eafff1e755c4b4372e4cf6f525dc626e80275d7 | |
parent | e766c7c3cd73ee9dc66266a0c1246a262ce51268 (diff) | |
download | Nim-b7f8dbbec2bc01f753100659f3db35b024e0076a.tar.gz |
fixes #1511
-rw-r--r-- | compiler/semstmts.nim | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/compiler/semstmts.nim b/compiler/semstmts.nim index 583185048..d394a2ae5 100644 --- a/compiler/semstmts.nim +++ b/compiler/semstmts.nim @@ -22,20 +22,23 @@ proc semDiscard(c: PContext, n: PNode): PNode = proc semBreakOrContinue(c: PContext, n: PNode): PNode = result = n checkSonsLen(n, 1) - if n.sons[0].kind != nkEmpty: - var s: PSym - case n.sons[0].kind - of nkIdent: s = lookUp(c, n.sons[0]) - of nkSym: s = n.sons[0].sym - else: illFormedAst(n) - if s.kind == skLabel and s.owner.id == c.p.owner.id: - var x = newSymNode(s) - x.info = n.info - incl(s.flags, sfUsed) - n.sons[0] = x - suggestSym(x.info, s) + if n.sons[0].kind != nkEmpty: + if n.kind != nkContinueStmt: + var s: PSym + case n.sons[0].kind + of nkIdent: s = lookUp(c, n.sons[0]) + of nkSym: s = n.sons[0].sym + else: illFormedAst(n) + if s.kind == skLabel and s.owner.id == c.p.owner.id: + var x = newSymNode(s) + x.info = n.info + incl(s.flags, sfUsed) + n.sons[0] = x + suggestSym(x.info, s) + else: + localError(n.info, errInvalidControlFlowX, s.name.s) else: - localError(n.info, errInvalidControlFlowX, s.name.s) + localError(n.info, errGenerated, "'continue' cannot have a label") elif (c.p.nestedLoopCounter <= 0) and (c.p.nestedBlockCounter <= 0): localError(n.info, errInvalidControlFlowX, renderTree(n, {renderNoComments})) |