-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Overloads passed to static proc parameters now convert to the desired…
… type mirroring proc params
- Loading branch information
Showing
4 changed files
with
28 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,16 @@ | ||
proc consumer[T: static proc(i: int): int{.nimcall.}](i: int): int = T(i) | ||
proc consumer(T: static proc(i: int): int{.nimcall.}, i: int): int = T(i) | ||
|
||
proc addIt(i: int): int = i + i | ||
proc add(i: int): int = i + i # Checks if we can use overloads | ||
proc squareIt(i: int): int = i * i | ||
|
||
assert consumer[addIt](10) == 20 | ||
assert consumer[add](10) == 20 | ||
assert consumer[squareIt](30) == 900 | ||
assert consumer[proc(i: int): int{.nimcall.} = i * i + i](10) == 110 | ||
|
||
|
||
assert consumer(addIt, 10) == 20 | ||
assert consumer(add, 10) == 20 | ||
assert consumer(squareIt, 30) == 900 | ||
assert consumer(proc(i: int): int{.nimcall.} = i * i + i, 10) == 110 |