forked from nim-lang/Nim
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
manual: Document the use of
static
as a proc call
Also adds tests. Fixes nim-lang#16987 .
- Loading branch information
1 parent
b155864
commit 8df50d8
Showing
3 changed files
with
43 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# issue# 16987 | ||
|
||
proc getNum(a: int): int = a | ||
|
||
# Below calls "doAssert getNum(123) == 123" at compile time. | ||
static: | ||
doAssert getNum(123) == 123 | ||
|
||
# Below calls evaluate the "getNum(123)" at compile time, but the | ||
# results of those calls get used at run time. | ||
doAssert getNum(123).static == 123 | ||
doAssert getNum(123).static() == 123 | ||
doAssert (static getNum(123)) == 123 | ||
doAssert (static(getNum(123))) == 123 |
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# issue# 16987 | ||
|
||
discard """ | ||
errormsg: "cannot evaluate at compile time: inp" | ||
nimout: ''' | ||
tstatic_callable_error.nim(14, 21) Error: cannot evaluate at compile time: inp''' | ||
""" | ||
|
||
|
||
# line 10 | ||
proc getNum(a: int): int = a | ||
|
||
let inp = 123 | ||
echo (static getNum(inp)) |