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
68' href='#n168'>168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333