Skip to content

Commit

Permalink
Small parser loop fix (#17904)
Browse files Browse the repository at this point in the history
* Fix loop on error with nim check in semiStmtList
* Add test
  • Loading branch information
Clyybber authored Apr 30, 2021
1 parent 20248a6 commit 76f9387
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions compiler/parser.nim
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,7 @@ proc semiStmtList(p: var Parser, result: PNode) =
let a = complexOrSimpleStmt(p)
if a.kind == nkEmpty:
parMessage(p, errExprExpected, p.tok)
getTok(p)
else:
result.add a
dec p.inSemiStmtList
Expand Down
5 changes: 4 additions & 1 deletion tests/parser/t15667.nim
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ t15667.nim(28, 5) Error: invalid indentation, maybe you forgot a '=' at t15667.n
t15667.nim(33, 5) Error: invalid indentation, maybe you forgot a '=' at t15667.nim(31, 25) ?
t15667.nim(42, 5) Error: invalid indentation, maybe you forgot a '=' at t15667.nim(38, 12) ?
t15667.nim(56, 5) Error: invalid indentation, maybe you forgot a '=' at t15667.nim(55, 13) ?
t15667.nim(61, 48) Error: expression expected, but found ','
'''
"""

Expand All @@ -16,7 +17,6 @@ t15667.nim(56, 5) Error: invalid indentation, maybe you forgot a '=' at t15667.n




# line 20
block:
proc fn1()
Expand Down Expand Up @@ -56,3 +56,6 @@ block:
runnableExamples:
discard
discard

# semiStmtList loop issue
proc bar(k:static bool):SomeNumber = (when k: 3, else: 3.0)

0 comments on commit 76f9387

Please sign in to comment.