summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2018-02-06 09:15:54 +0100
committerAndreas Rumpf <rumpf_a@web.de>2018-02-06 09:15:54 +0100
commit2199f8328059ffa62400acc7342b36dd50aed7e2 (patch)
treebdc2d80961edad2a8cfd4f46b2f185805df3340e
parentfa0f5d0238d5656ace070b86ecc9cdec60568fdb (diff)
downloadNim-2199f8328059ffa62400acc7342b36dd50aed7e2.tar.gz
improve error message for twrongcolon
-rw-r--r--compiler/parser.nim4
-rw-r--r--compiler/semcall.nim4
-rw-r--r--tests/errmsgs/twrongcolon.nim11
3 files changed, 15 insertions, 4 deletions
diff --git a/compiler/parser.nim b/compiler/parser.nim
index b1cfd7609..4974abcc3 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 a8ab2f742..01f291017 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 000000000..6f5cc3e5d
--- /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