From 2199f8328059ffa62400acc7342b36dd50aed7e2 Mon Sep 17 00:00:00 2001 From: Andreas Rumpf Date: Tue, 6 Feb 2018 09:15:54 +0100 Subject: [PATCH] improve error message for twrongcolon --- compiler/parser.nim | 4 ++-- compiler/semcall.nim | 4 ++-- tests/errmsgs/twrongcolon.nim | 11 +++++++++++ 3 files changed, 15 insertions(+), 4 deletions(-) create mode 100644 tests/errmsgs/twrongcolon.nim diff --git a/compiler/parser.nim b/compiler/parser.nim index b1cfd76090..4974abcc33 100644 --- a/compiler/parser.nim +++ b/compiler/parser.nim @@ -914,7 +914,7 @@ proc parseIdentColonEquals(p: var TParser, flags: TDeclaredIdentFlags): PNode = optInd(p, result) addSon(result, parseTypeDesc(p)) else: - addSon(result, ast.emptyNode) + addSon(result, newNodeP(nkEmpty, p)) if p.tok.tokType != tkEquals and withBothOptional notin flags: parMessage(p, errColonOrEqualsExpected, p.tok) if p.tok.tokType == tkEquals: @@ -922,7 +922,7 @@ proc parseIdentColonEquals(p: var TParser, flags: TDeclaredIdentFlags): PNode = optInd(p, result) addSon(result, parseExpr(p)) else: - addSon(result, ast.emptyNode) + addSon(result, newNodeP(nkEmpty, p)) proc parseTuple(p: var TParser, indentAllowed = false): PNode = #| inlTupleDecl = 'tuple' diff --git a/compiler/semcall.nim b/compiler/semcall.nim index a8ab2f7429..01f2910175 100644 --- a/compiler/semcall.nim +++ b/compiler/semcall.nim @@ -277,9 +277,9 @@ proc resolveOverloads(c: PContext, n, orig: PNode, if overloadsState == csEmpty and result.state == csEmpty: if nfDotField in n.flags and nfExplicitCall notin n.flags: - localError(n.info, errUndeclaredField, considerQuotedIdent(f).s) + localError(n.info, errUndeclaredField, considerQuotedIdent(f, n).s) else: - localError(n.info, errUndeclaredRoutine, considerQuotedIdent(f).s) + localError(n.info, errUndeclaredRoutine, considerQuotedIdent(f, n).s) return elif result.state != csMatch: if nfExprCall in n.flags: diff --git a/tests/errmsgs/twrongcolon.nim b/tests/errmsgs/twrongcolon.nim new file mode 100644 index 0000000000..6f5cc3e5d5 --- /dev/null +++ b/tests/errmsgs/twrongcolon.nim @@ -0,0 +1,11 @@ +discard """ +errormsg: "in expression '(" +nimout: ''' +Error: in expression '( + 890)': identifier expected, but found '' +''' + +line: 11 +""" + +var n: int : 890