diff --git a/compiler/types.nim b/compiler/types.nim index 60d8120688..ec310e2483 100644 --- a/compiler/types.nim +++ b/compiler/types.nim @@ -232,7 +232,11 @@ proc iterOverTypeAux(marker: var IntSet, t: PType, iter: TTypeIter, if result: return if not containsOrIncl(marker, t.id): case t.kind - of tyGenericInst, tyGenericBody, tyAlias, tySink, tyInferred: + of tyGenericBody: + # treat as atomic, containsUnresolvedType wants always false, + # containsGenericType always gives true + discard + of tyGenericInst, tyAlias, tySink, tyInferred: result = iterOverTypeAux(marker, skipModifier(t), iter, closure) else: for a in t.kids: diff --git a/tests/generics/tuninstantiatedgenericcalls.nim b/tests/generics/tuninstantiatedgenericcalls.nim index 308b1f33e0..42f5493d7f 100644 --- a/tests/generics/tuninstantiatedgenericcalls.nim +++ b/tests/generics/tuninstantiatedgenericcalls.nim @@ -438,6 +438,16 @@ block: # issue #24090 block: # above but encountered by sigmatch using replaceTypeVarsN type Opt[T] = object + x: T proc none[T](x: type Opt, y: typedesc[T]): Opt[T] = discard proc foo[T](x: T, a = Opt.none(int)) = discard foo(1, a = Opt.none(int)) + foo(1) + +block: # real version of above + type Opt[T] = object + x: T + template none(x: type Opt, T: type): Opt[T] = Opt[T]() + proc foo[T](x: T, a = Opt.none(int)) = discard + foo(1, a = Opt.none(int)) + foo(1)