summary refs log tree commit diff stats
path: root/compiler/semcall.nim
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2018-09-03 16:07:35 +0200
committerAraq <rumpf_a@web.de>2018-09-03 16:07:44 +0200
commit0694c9080f85b59e86ddfb0bd3c799fe9d9e30ae (patch)
treeb150f0a27b07303b8394360258b3d9023ddf2983 /compiler/semcall.nim
parente63c66b8104225cefe0413471410ef4c072f9954 (diff)
downloadNim-0694c9080f85b59e86ddfb0bd3c799fe9d9e30ae.tar.gz
fixes #8043
Diffstat (limited to 'compiler/semcall.nim')
-rw-r--r--compiler/semcall.nim11
1 files changed, 7 insertions, 4 deletions
diff --git a/compiler/semcall.nim b/compiler/semcall.nim
index 9e75f8cd4..53f7045dd 100644
--- a/compiler/semcall.nim
+++ b/compiler/semcall.nim
@@ -189,15 +189,18 @@ proc presentFailedCandidates(c: PContext, n: PNode, errors: CandidateErrors):
     if err.firstMismatch != 0 and n.len > 1:
       let cond = n.len > 2
       if cond:
-        candidates.add("  first type mismatch at position: " & $err.firstMismatch &
-          "\n  required type: ")
+        candidates.add("  first type mismatch at position: " & $abs(err.firstMismatch))
+        if err.firstMismatch >= 0: candidates.add("\n  required type: ")
+        else: candidates.add("\n  unknown named parameter: " & $n[-err.firstMismatch][0])
       var wanted, got: PType = nil
-      if err.firstMismatch < err.sym.typ.len:
+      if err.firstMismatch < 0:
+        discard
+      elif err.firstMismatch < err.sym.typ.len:
         wanted = err.sym.typ.sons[err.firstMismatch]
         if cond: candidates.add typeToString(wanted)
       else:
         if cond: candidates.add "none"
-      if err.firstMismatch < n.len:
+      if err.firstMismatch > 0 and err.firstMismatch < n.len:
         if cond:
           candidates.add "\n  but expression '"
           candidates.add renderTree(n[err.firstMismatch])