You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Nim Compiler Version 2.2.2 [Linux: amd64]
Linux 6.6.56, NixOS 24.11
Description
I'm attempting to define a concept using a function implemented for another generic concept.
The following example compiles with old-styled concepts, but fails with new-styled concepts:
test.nim:
typeIndexable[T] =conceptproc`[]`(t: Self, i: int): T
proclen(t: Self): intiteratoritems[T](t: Indexable[T]): T =for i in0..< t.len:
yield t[i]
# With new-styled concepts: type mismatchtypeEnumerable[T] =conceptiteratoritems(t: Self): T
# With old-styled concepts: works# type Enumerable[T] = concept c# items(c) is TprocechoAll[T](t: Enumerable[T]) =for item in t:
echo item
typeDummyIndexable[T] =distinctseq[T]
proc`[]`[T](t: DummyIndexable[T], i: int): T =seq[T](t)[i]
proclen[T](t: DummyIndexable[T]): int=seq[T](t).len
let dummyIndexable =DummyIndexable(@[1, 2])
echoAll(dummyIndexable)
Current Output
test.nim(33, 8) Error: type mismatch
Expression: echoAll(dummyIndexable)
[1] dummyIndexable: DummyIndexable[system.int]
Expected one of (first mismatch at [position]):
[1] proc echoAll[T](t: Enumerable[T])
Expected Output
1
2
Known Workarounds
Using old-styled concepts (as commented in the example snippet) works.
Additional Information
No response
The text was updated successfully, but these errors were encountered:
Nim Version
Nim Compiler Version 2.2.2 [Linux: amd64]
Linux 6.6.56, NixOS 24.11
Description
I'm attempting to define a concept using a function implemented for another generic concept.
The following example compiles with old-styled concepts, but fails with new-styled concepts:
test.nim:
Current Output
Expected Output
Known Workarounds
Using old-styled concepts (as commented in the example snippet) works.
Additional Information
No response
The text was updated successfully, but these errors were encountered: