mirror of
https://github.com/nim-lang/Nim.git
synced 2025-12-28 08:54:53 +00:00
Add tySet to concept matching (#24908)
This commit is contained in:
@@ -419,6 +419,10 @@ proc matchType(c: PContext; fo, ao: PType; m: var MatchCon): bool =
|
||||
result = matchType(c, ff, a, m)
|
||||
if result: break # and remember the binding!
|
||||
m.bindings.setToPreviousLayer()
|
||||
of tySet:
|
||||
result = false
|
||||
if a.kind == tySet:
|
||||
result = matchType(c, f.elementType, a.elementType, m)
|
||||
else:
|
||||
result = false
|
||||
if result and ao.kind == tyGenericParam:
|
||||
|
||||
@@ -485,6 +485,18 @@ block:
|
||||
assert Container[AsyncImpl] isnot SyncType
|
||||
assert Container[AsyncImpl] is AsyncType
|
||||
|
||||
block:
|
||||
type
|
||||
C1 = concept
|
||||
proc p(x: typedesc[Self]): int
|
||||
E1 = enum
|
||||
One, Two
|
||||
proc p[E: enum](x: typedesc[set[E]]): int = sizeof(set[E])
|
||||
|
||||
proc spring(x: C1) = discard
|
||||
|
||||
spring({One,Two})
|
||||
|
||||
# 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