summary refs log tree commit diff stats
path: root/compiler
diff options
context:
space:
mode:
authorTimothee Cour <timothee.cour2@gmail.com>2019-08-08 05:41:23 -0700
committerAndreas Rumpf <rumpf_a@web.de>2019-08-08 14:41:23 +0200
commitfda51b6ca2040ee3a6362291da872a7fbfe2b8e2 (patch)
treef867f6436a189a887e7ce5827d445be07098df7b /compiler
parent756fabb97982c7ec1da74f99c4aad3ae2f3dfd60 (diff)
downloadNim-fda51b6ca2040ee3a6362291da872a7fbfe2b8e2.tar.gz
fix crash on sigmatch (#11913)
Diffstat (limited to 'compiler')
-rw-r--r--compiler/semcall.nim1
-rw-r--r--compiler/sigmatch.nim6
2 files changed, 4 insertions, 3 deletions
diff --git a/compiler/semcall.nim b/compiler/semcall.nim
index aa263fdee..5796abbff 100644
--- a/compiler/semcall.nim
+++ b/compiler/semcall.nim
@@ -196,6 +196,7 @@ proc presentFailedCandidates(c: PContext, n: PNode, errors: CandidateErrors):
       case err.firstMismatch.kind
       of kUnknownNamedParam: candidates.add("\n  unknown named parameter: " & $nArg[0])
       of kAlreadyGiven: candidates.add("\n  named param already provided: " & $nArg[0])
+      of kPositionalAlreadyGiven: candidates.add("\n  positional param was already given as named param")
       of kExtraArg: candidates.add("\n  extra argument given")
       of kMissingParam: candidates.add("\n  missing parameter: " & nameParam)
       of kTypeMismatch, kVarNeeded:
diff --git a/compiler/sigmatch.nim b/compiler/sigmatch.nim
index be4f15652..b2ca88359 100644
--- a/compiler/sigmatch.nim
+++ b/compiler/sigmatch.nim
@@ -21,7 +21,7 @@ when (defined(booting) or defined(nimsuggest)) and not defined(leanCompiler):
 type
   MismatchKind* = enum
     kUnknown, kAlreadyGiven, kUnknownNamedParam, kTypeMismatch, kVarNeeded,
-    kMissingParam, kExtraArg
+    kMissingParam, kExtraArg, kPositionalAlreadyGiven
 
   MismatchInfo* = object
     kind*: MismatchKind # reason for mismatch
@@ -2432,8 +2432,8 @@ proc matchesAux(c: PContext, n, nOrig: PNode,
         formal = m.callee.n.sons[f].sym
         m.firstMismatch.kind = kTypeMismatch
         if containsOrIncl(marker, formal.position) and container.isNil:
-          m.firstMismatch.kind = kAlreadyGiven
-          # already in namedParams: (see above remark)
+          m.firstMismatch.kind = kPositionalAlreadyGiven
+          # positional param already in namedParams: (see above remark)
           when false: localError(n.sons[a].info, errCannotBindXTwice, formal.name.s)
           noMatch()
           return