From 422327c01005ae0c7c7238636a96e741923a77d8 Mon Sep 17 00:00:00 2001 From: Araq Date: Wed, 2 Oct 2013 07:57:30 +0200 Subject: [PATCH] fixed another semicolon related parsing bug --- compiler/parser.nim | 7 +++---- tests/{compile => run}/tindent1.nim | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+), 4 deletions(-) rename tests/{compile => run}/tindent1.nim (69%) diff --git a/compiler/parser.nim b/compiler/parser.nim index 1411043e4..e8439466a 100644 --- a/compiler/parser.nim +++ b/compiler/parser.nim @@ -1798,10 +1798,9 @@ proc parseStmt(p: var TParser): PNode = if p.tok.indent == p.currInd: nil elif p.tok.tokType == tkSemicolon: - while p.tok.tokType == tkSemicolon: - getTok(p) - if p.tok.indent < 0 or p.tok.indent == p.currInd: discard - else: return + getTok(p) + if p.tok.indent < 0 or p.tok.indent == p.currInd: discard + else: break else: if p.tok.indent > p.currInd: parMessage(p, errInvalidIndentation) diff --git a/tests/compile/tindent1.nim b/tests/run/tindent1.nim similarity index 69% rename from tests/compile/tindent1.nim rename to tests/run/tindent1.nim index 0527b6e57..78a303783 100644 --- a/tests/compile/tindent1.nim +++ b/tests/run/tindent1.nim @@ -1,3 +1,6 @@ +discard """ + output: '''Success''' +""" const romanNumbers1 = [ @@ -22,3 +25,18 @@ const romanNumbers4 = [ ] +proc main = + var j = 0 + while j < 10: + inc(j); + + if j == 5: doAssert false + +var j = 0 +while j < 10: + inc(j); + +if j == 5: doAssert false + +main() +echo "Success"