diff options
-rw-r--r-- | compiler/parser.nim | 27 | ||||
-rw-r--r-- | tests/macros/tlexerex.nim | 5 |
2 files changed, 16 insertions, 16 deletions
diff --git a/compiler/parser.nim b/compiler/parser.nim index d549e1358..8b335efd5 100644 --- a/compiler/parser.nim +++ b/compiler/parser.nim @@ -1168,19 +1168,20 @@ proc postExprBlocks(p: var TParser, x: PNode): PNode = result = makeCall(result) getTok(p) skipComment(p, result) - var stmtList = newNodeP(nkStmtList, p) - let body = parseStmt(p) - stmtList.add body - - if stmtList.len == 1 and stmtList[0].kind == nkStmtList: - # to keep backwards compatibility (see tests/vm/tstringnil) - stmtList = stmtList[0] - - if openingParams.kind != nkEmpty: - result.add newProcNode(nkDo, stmtList.info, stmtList, - params = openingParams, pragmas = openingPragmas) - else: - result.add stmtList + if p.tok.tokType notin {tkOf, tkElif, tkElse, tkExcept}: + var stmtList = newNodeP(nkStmtList, p) + let body = parseStmt(p) + stmtList.add body + + if stmtList.len == 1 and stmtList[0].kind == nkStmtList: + # to keep backwards compatibility (see tests/vm/tstringnil) + stmtList = stmtList[0] + + if openingParams.kind != nkEmpty: + result.add newProcNode(nkDo, stmtList.info, stmtList, + params = openingParams, pragmas = openingPragmas) + else: + result.add stmtList while sameInd(p): var nextBlock: PNode diff --git a/tests/macros/tlexerex.nim b/tests/macros/tlexerex.nim index d348a4bcc..db2c38ef6 100644 --- a/tests/macros/tlexerex.nim +++ b/tests/macros/tlexerex.nim @@ -1,8 +1,7 @@ - import macros -macro match*(s: cstring|string; pos: int; sections: untyped): untyped = - for sec in sections.children: +macro match*(s: cstring|string; pos: int; sections: varargs[untyped]): untyped = + for sec in sections: expectKind sec, nnkOfBranch expectLen sec, 2 result = newStmtList() |