summary refs log tree commit diff stats
path: root/compiler
diff options
context:
space:
mode:
authorLemonBoy <LemonBoy@users.noreply.github.com>2018-08-20 16:54:13 +0200
committerAndreas Rumpf <rumpf_a@web.de>2018-08-20 16:54:13 +0200
commitb28c7d434b16ebd9cc33ef1d6b267b49660153ba (patch)
tree226ddfa6fbb2f967abfaed46be7dc965396c95f9 /compiler
parent2def61606912625f3d20076e6686235996f25e62 (diff)
downloadNim-b28c7d434b16ebd9cc33ef1d6b267b49660153ba.tar.gz
Update all the default parameters after an instantiation (#8689)
The old implementation relied on the (now?) wrong assumption that
default-valued parameters can only be placed after the required ones.

Fixes #8683
Diffstat (limited to 'compiler')
-rw-r--r--compiler/semcall.nim11
1 files changed, 5 insertions, 6 deletions
diff --git a/compiler/semcall.nim b/compiler/semcall.nim
index ef452fcdc..dc71f2567 100644
--- a/compiler/semcall.nim
+++ b/compiler/semcall.nim
@@ -399,12 +399,11 @@ proc updateDefaultParams(call: PNode) =
   # the default params with `nfDefaultParam` and `instantiateProcType`
   # computes correctly the default values for each instantiation.
   let calleeParams = call[0].sym.typ.n
-  for i in countdown(call.len - 1, 1):
-    if nfDefaultParam notin call[i].flags:
-      return
-    let def = calleeParams[i].sym.ast
-    if nfDefaultRefsParam in def.flags: call.flags.incl nfDefaultRefsParam
-    call[i] = def
+  for i in 1..<call.len:
+    if nfDefaultParam in call[i].flags:
+      let def = calleeParams[i].sym.ast
+      if nfDefaultRefsParam in def.flags: call.flags.incl nfDefaultRefsParam
+      call[i] = def
 
 proc semResolvedCall(c: PContext, x: TCandidate,
                      n: PNode, flags: TExprFlags): PNode =