Add tySet to concept matching (#24908)

This commit is contained in:
Ryan McConnell
2025-04-24 15:17:42 -04:00
committed by GitHub
parent d966ee3fc3
commit 5dcfd8d7bb
2 changed files with 16 additions and 0 deletions

View File

@@ -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:

View File

@@ -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