summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--compiler/semcall.nim11
-rw-r--r--tests/proc/t8683.nim11
2 files changed, 16 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 =
diff --git a/tests/proc/t8683.nim b/tests/proc/t8683.nim
new file mode 100644
index 000000000..8c7e7af08
--- /dev/null
+++ b/tests/proc/t8683.nim
@@ -0,0 +1,11 @@
+discard """
+  output: "1"
+"""
+
+proc foo[T](bar: proc (x, y: T): int = system.cmp, baz: int) =
+  echo "1"
+
+proc foo[T](bar: proc (x, y: T): int = system.cmp) =
+  echo "2"
+
+foo[int](baz = 5)