summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--compiler/sigmatch.nim3
-rw-r--r--tests/overload/tparam_forwarding.nim15
2 files changed, 17 insertions, 1 deletions
diff --git a/compiler/sigmatch.nim b/compiler/sigmatch.nim
index 7e566afad..716a4f54a 100644
--- a/compiler/sigmatch.nim
+++ b/compiler/sigmatch.nim
@@ -2173,7 +2173,8 @@ proc matchesAux(c: PContext, n, nOrig: PNode,
   var formal: PSym = if formalLen > 1: m.callee.n.sons[1].sym else: nil
 
   while a < n.len:
-    if a >= formalLen-1 and formal != nil and formal.typ.isVarargsUntyped:
+    if a >= formalLen-1 and f < formalLen and m.callee.n[f].typ.isVarargsUntyped:
+      formal = m.callee.n.sons[f].sym
       incl(marker, formal.position)
       if container.isNil:
         container = newNodeIT(nkArgList, n.sons[a].info, arrayConstr(c, n.info))
diff --git a/tests/overload/tparam_forwarding.nim b/tests/overload/tparam_forwarding.nim
index c1b276bfc..cd3de32e3 100644
--- a/tests/overload/tparam_forwarding.nim
+++ b/tests/overload/tparam_forwarding.nim
@@ -6,6 +6,10 @@ output: '''baz
 a
 b
 c
+x: 1, y: test 1
+x: 2, y: test 2
+x: 10, y: test 3
+x: 4, y: test 4
 '''
 """
 
@@ -35,3 +39,14 @@ templateForwarding fooVarargs, "test".len > 3, Foo(x: 10), Foo(x: 100), Foo(x: 1
 
 procForwarding "a", "b", "c"
 
+proc hasKeywordArgs(x = 10, y = "y") =
+  echo "x: ", x, ", y: ", y
+
+proc hasRegularArgs(x: int, y: string) =
+  echo "x: ", x, ", y: ", y
+
+templateForwarding(hasRegularArgs, true, 1, "test 1")
+templateForwarding(hasKeywordArgs, true, 2, "test 2")
+templateForwarding(hasKeywordArgs, true, y = "test 3")
+templateForwarding(hasKeywordArgs, true, y = "test 4", x = 4)
+
381268ed'>^
a13ad5be ^

34b02351 ^
9a3cd69e ^
34b02351 ^
5268aada
5d6af7f5 ^
15815d72 ^
ca86dcd3 ^
06fbb9bc ^
f7cf612a ^
2014e1e0 ^
15815d72 ^
a13ad5be ^
5268aada
ca86dcd3 ^

a13ad5be ^
ca86dcd3 ^
8fd4662c ^


a13ad5be ^
8fd4662c ^
a13ad5be ^
ca86dcd3 ^


06fbb9bc ^



ca86dcd3 ^




a13ad5be ^

f7cf612a ^





ca86dcd3 ^
8fd4662c ^


06fbb9bc ^
f7cf612a ^

9a3cd69e ^
f7cf612a ^

a13ad5be ^
8fd4662c ^
a13ad5be ^

54623b97 ^
a13ad5be ^


8fd4662c ^














b3b97465 ^



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100