diff options
author | Araq <rumpf_a@web.de> | 2018-03-18 12:04:22 +0100 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2018-03-18 12:04:22 +0100 |
commit | b0994c7f929395217b3caeb2699add29f35ff61e (patch) | |
tree | 16ae116d1994b75a0e2a1234738dc88a0c03f0f5 /compiler/parser.nim | |
parent | 4301744e49f4b3758cc7a777c2d78c827bfbb344 (diff) | |
download | Nim-b0994c7f929395217b3caeb2699add29f35ff61e.tar.gz |
better error messages
Diffstat (limited to 'compiler/parser.nim')
-rw-r--r-- | compiler/parser.nim | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/compiler/parser.nim b/compiler/parser.nim index 1ae7646cd..debb0b34d 100644 --- a/compiler/parser.nim +++ b/compiler/parser.nim @@ -820,7 +820,6 @@ proc parseIfExpr(p: var TParser, kind: TNodeKind): PNode = if realInd(p): p.currInd = p.tok.indent wasIndented = true - echo result.info, " yes ", p.currInd addSon(branch, parseExpr(p)) result.add branch while sameInd(p) or not wasIndented: @@ -964,6 +963,8 @@ proc parseTuple(p: var TParser, indentAllowed = false): PNode = parMessage(p, errIdentifierExpected, p.tok) break if not sameInd(p): break + elif p.tok.tokType == tkParLe: + parMessage(p, errGenerated, "the syntax for tuple types is 'tuple[...]', not 'tuple(...)'") else: result = newNodeP(nkTupleClassTy, p) @@ -985,6 +986,9 @@ proc parseParamList(p: var TParser, retColon = true): PNode = a = parseIdentColonEquals(p, {withBothOptional, withPragma}) of tkParRi: break + of tkVar: + parMessage(p, errGenerated, "the syntax is 'parameter: var T', not 'var parameter: T'") + break else: parMessage(p, errTokenExpected, ")") break @@ -2132,7 +2136,12 @@ proc parseTopLevelStmt(p: var TParser): PNode = if p.tok.indent != 0: if p.firstTok and p.tok.indent < 0: discard elif p.tok.tokType != tkSemiColon: - parMessage(p, errInvalidIndentation) + # special casing for better error messages: + if p.tok.tokType == tkOpr and p.tok.ident.s == "*": + parMessage(p, errGenerated, + "invalid indentation; an export marker '*' follows the declared identifier") + else: + parMessage(p, errInvalidIndentation) p.firstTok = false case p.tok.tokType of tkSemiColon: |