From bab1f67971556f8cea4e1b082403165014e51135 Mon Sep 17 00:00:00 2001 From: Andreas Rumpf Date: Sun, 7 Jul 2019 15:25:25 +0200 Subject: [PATCH] fixes #11660 (#11677) --- compiler/semtypinst.nim | 5 ++++- tests/misc/tparamsindefault.nim | 6 ++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/compiler/semtypinst.nim b/compiler/semtypinst.nim index 479f88bf01c6..af840e80c73e 100644 --- a/compiler/semtypinst.nim +++ b/compiler/semtypinst.nim @@ -539,7 +539,10 @@ proc replaceTypeVarsTAux(cl: var TReplTypeVars, t: PType): PType = let lookup = cl.typeMap.lookup(t) if lookup != nil: result = lookup - if tfUnresolved in t.flags or cl.skipTypedesc: result = result.base + if result.kind != tyTypeDesc: + result = makeTypeDesc(cl.c, result) + elif tfUnresolved in t.flags or cl.skipTypedesc: + result = result.base elif t.sons[0].kind != tyNone: result = makeTypeDesc(cl.c, replaceTypeVarsT(cl, t.sons[0])) diff --git a/tests/misc/tparamsindefault.nim b/tests/misc/tparamsindefault.nim index c678dcc6006b..3fe917f2bd6d 100644 --- a/tests/misc/tparamsindefault.nim +++ b/tests/misc/tparamsindefault.nim @@ -18,6 +18,7 @@ f3 10 15 25 true true false true world +typedescDefault ''' """ @@ -112,3 +113,8 @@ block: echo pySubstr("Hello world", -5) + +# bug #11660 + +func typedescDefault(T: typedesc; arg: T = 0) = debugEcho "typedescDefault" +typedescDefault(int)