diff --git a/compiler/concepts.nim b/compiler/concepts.nim index b18956c3b0..1c8860bd5f 100644 --- a/compiler/concepts.nim +++ b/compiler/concepts.nim @@ -347,10 +347,11 @@ proc matchType(c: PContext; fo, ao: PType; m: var MatchCon): bool = k1 = f.kidsLen - ord(f.kind == tyGenericInst) k2 = ea.kidsLen - ord(ea.kind == tyGenericInst) if sameType(f.genericHead, ea.genericHead) and k1 == k2: + result = true for i in 1 ..< k2: if not matchType(c, f[i], ea[i], m): + result = false break - result = true of tyOrdinal: result = isOrdinalType(a, allowEnumWithHoles = false) or a.kind == tyGenericParam of tyStatic: diff --git a/tests/concepts/tconceptsv2.nim b/tests/concepts/tconceptsv2.nim index afa66eda33..83a19348b1 100644 --- a/tests/concepts/tconceptsv2.nim +++ b/tests/concepts/tconceptsv2.nim @@ -459,6 +459,32 @@ block: var s = ArrayBuffer[1500]() spring(s, 8.uint8) +block: + type + Future[T] = object + SyncType = concept + proc p(s: Self) + AsyncType = concept + proc p(s: Self) : Future[void] + SyncImpl = object + AsyncImpl = object + Container[T] = object + + proc p(x: SyncImpl) = discard + proc p(x: AsyncImpl): Future[void] = discard + + proc p(x: Container[SyncType]) = discard + proc p(x: Container[AsyncImpl]): Future[void] = discard + + assert SyncImpl is SyncType + assert SyncImpl isnot AsyncType + assert AsyncImpl isnot SyncType + assert AsyncImpl is AsyncType + assert Container[SyncImpl] is SyncType + assert Container[SyncImpl] isnot AsyncType + assert Container[AsyncImpl] isnot SyncType + assert Container[AsyncImpl] is AsyncType + # this code fails inside a block for some reason type Indexable[T] = concept proc `[]`(t: Self, i: int): T