Skip to content

Commit

Permalink
Make helpers.-> use edge.->
Browse files Browse the repository at this point in the history
The original `->` in `edge` sorts the parameters before forming the edge, but helpers.`->` doesn't do this.

helpers.`->` also has a more precise signature (on `tuple[x, y: float]` rather than the `Point` concept), which means generic procs can prefer it if `->` is considered to be overloaded.

This has not been an issue in this package because the generic procs that use `->` only have access to 1 overload of it and so Nim considers them not overloaded. However this behavior is not reliable: nim-lang/Nim#11184, and so attempts to fix this cause issues in this library's tests.

Alternatively the tests can use another operator to form unsorted edges, or the signature of helpers.`->` can be made equally as precise as the one in `edge` (i.e. defined on `Point`).
  • Loading branch information
metagn authored and Nycto committed Sep 30, 2023
1 parent 87802f6 commit 0274f0e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion tests/helpers.nim
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ proc p*( x, y: float ): tuple[x, y: float] =

proc `->`*( a, b: tuple[x, y: float] ): Edge[tuple[x, y: float]] =
## Creates an edge from two tuples
result = (a: a, b: b)
result = edge.`->`(a, b)

proc `==`*[T]( actual: seq[T], expected: openArray[T] ): bool =
## Allows you to compare a sequence to an array
Expand Down

0 comments on commit 0274f0e

Please sign in to comment.