Skip to content

Commit

Permalink
disallow 'continue' that is not used within a loop; fixes #6367
Browse files Browse the repository at this point in the history
  • Loading branch information
Araq committed Oct 18, 2018
1 parent c64391e commit 604dfeb
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion compiler/semstmts.nim
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ proc semBreakOrContinue(c: PContext, n: PNode): PNode =
localError(c.config, n.info, errInvalidControlFlowX % s.name.s)
else:
localError(c.config, n.info, errGenerated, "'continue' cannot have a label")
elif (c.p.nestedLoopCounter <= 0) and (c.p.nestedBlockCounter <= 0):
elif (c.p.nestedLoopCounter <= 0) and ((c.p.nestedBlockCounter <= 0) or n.kind == nkContinueStmt):
localError(c.config, n.info, errInvalidControlFlowX %
renderTree(n, {renderNoComments}))

Expand Down

0 comments on commit 604dfeb

Please sign in to comment.