summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorSirOlaf <34164198+SirOlaf@users.noreply.github.com>2023-08-10 07:56:09 +0200
committerGitHub <noreply@github.com>2023-08-10 07:56:09 +0200
commitbaf350493b08d5e1ee25f61b7d7eff33c3499487 (patch)
tree1c6bd881efab1037ace3227622dc2380dc85117f
parentfa58d23080dad13283cd180260b14cf8c57ab501 (diff)
downloadNim-baf350493b08d5e1ee25f61b7d7eff33c3499487.tar.gz
Fix #21760 (#22422)
* Remove call-specific replaceTypeVarsN

* Run for all call kinds and ignore typedesc

* Testcase

---------

Co-authored-by: SirOlaf <>
-rw-r--r--compiler/seminst.nim4
-rw-r--r--tests/generics/t21760.nim8
2 files changed, 10 insertions, 2 deletions
diff --git a/compiler/seminst.nim b/compiler/seminst.nim
index 22d28999d..0dc3e3cfc 100644
--- a/compiler/seminst.nim
+++ b/compiler/seminst.nim
@@ -275,9 +275,9 @@ proc instantiateProcType(c: PContext, pt: TIdTable,
     # call head symbol, because this leads to infinite recursion.
     if oldParam.ast != nil:
       var def = oldParam.ast.copyTree
-      if def.kind == nkCall:
+      if def.kind in nkCallKinds:
         for i in 1..<def.len:
-          def[i] = replaceTypeVarsN(cl, def[i])
+          def[i] = replaceTypeVarsN(cl, def[i], 1)
 
       def = semExprWithType(c, def)
       if def.referencesAnotherParam(getCurrOwner(c)):
diff --git a/tests/generics/t21760.nim b/tests/generics/t21760.nim
new file mode 100644
index 000000000..5343279bb
--- /dev/null
+++ b/tests/generics/t21760.nim
@@ -0,0 +1,8 @@
+import std/tables
+
+type Url = object
+
+proc myInit(_: type[Url], params = default(Table[string, string])): Url =
+  discard
+
+discard myInit(Url)
\ No newline at end of file