Skip to content

Commit

Permalink
add test to close nim-lang#7209
Browse files Browse the repository at this point in the history
was fixed by nim-lang#22029
  • Loading branch information
metagn committed Jun 16, 2023
1 parent 0a19d78 commit 57b772a
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions tests/statictypes/tstaticgenericparam.nim
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,16 @@ block: # issue #19365
doAssert ss == @["123: int"]
f("abc")
doAssert ss == @["123: int", "abc: string"]

block: # issue #7209
type Modulo[A; M: static[A]] = distinct A

proc `$`[A; M: static[A]](x: Modulo[A, M]): string =
$(A(x)) & " mod " & $(M)

proc modulo[A](a: A, M: static[A]): Modulo[A, M] = Modulo[A, M](a %% M)

proc `+`[A; M: static[A]](x, y: Modulo[A, M]): Modulo[A, M] =
(A(x) + A(y)).modulo(M)

doAssert (3.modulo(7) + 5.modulo(7)) == "1 mod 7"

0 comments on commit 57b772a

Please sign in to comment.