diff --git a/compiler/semtypes.nim b/compiler/semtypes.nim index 22d70fa64e..3d53f3d1e3 100644 --- a/compiler/semtypes.nim +++ b/compiler/semtypes.nim @@ -2006,7 +2006,9 @@ proc semTypeIdent(c: PContext, n: PNode): PSym = # proc signature for example if c.inGenericInst > 0: let bound = result.typ.elementType.sym - if bound != nil: return bound + # the symbol may still point to the uninstantiated generic body type + if bound != nil and bound.typ == result.typ.elementType: + return bound return result if result.typ.sym == nil: localError(c.config, n.info, errTypeExpected) diff --git a/tests/generics/tgenerics_issues.nim b/tests/generics/tgenerics_issues.nim index da202874e1..e865c8f7be 100644 --- a/tests/generics/tgenerics_issues.nim +++ b/tests/generics/tgenerics_issues.nim @@ -902,3 +902,15 @@ block: # issue #25494 a, b, c foo[MyEnum]() + +block: # issue #25005 + type + RpcResponse[T] = ref object + result: T + + func testit[T](p: var ref T) = + p = new(T) + + var v: RpcResponse[string] + testit(v) +