mirror of
https://github.com/nim-lang/Nim.git
synced 2026-07-12 12:19:40 +00:00
I don't like it, but seems like this is correct. Concept type classes have to behave like other "named" type classes and participate in "bind once" mechanics or require some weird semantics. As a side note I'm pretty sure the `tuple` example in the manual explaining this is either wrong now or has regressed, but I don't think it matters because I doubt anyone thinks about this feature much. #25778
29 lines
418 B
Nim
29 lines
418 B
Nim
discard """
|
|
action: "reject"
|
|
errormsg: "type mismatch"
|
|
"""
|
|
|
|
type
|
|
Dollarable = concept
|
|
proc `$`(x: Self): string
|
|
|
|
proc checkEqual(x, y: Dollarable) =
|
|
if x != y:
|
|
echo $x
|
|
echo $y
|
|
|
|
type
|
|
StateFlags = enum
|
|
sfMatch
|
|
sfSoft
|
|
|
|
MatchKind = enum
|
|
NoFurtherMatch
|
|
NoMatch
|
|
Match
|
|
AllFurtherMatch
|
|
|
|
proc `==`(a: set[StateFlags]; b: MatchKind): bool = true
|
|
|
|
checkEqual({sfMatch, sfSoft}, Match)
|