mirror of
https://github.com/nim-lang/Nim.git
synced 2025-12-28 17:04:41 +00:00
new-style concept bugfix (#24858)
Combining two small PRs in one here. The test case explains what was
wrong with the concepts and for naitivesockets, it's typical to adjust
`ai_flags` so I opened that up.
(cherry picked from commit d4098e6ca0)
This commit is contained in:
committed by
narimiran
parent
72190536cb
commit
ee44fe197b
@@ -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:
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user