follow #11707(add pragmas examples for =>) (#15863)

(cherry picked from commit 9fd67958b9)
This commit is contained in:
flywind
2020-11-06 18:42:43 +08:00
committed by narimiran
parent ac32cf129b
commit 839ec1395d

View File

@@ -57,12 +57,22 @@ proc createProcType(p, b: NimNode): NimNode {.compileTime.} =
macro `=>`*(p, b: untyped): untyped =
## Syntax sugar for anonymous procedures.
## It also supports pragmas.
runnableExamples:
proc passTwoAndTwo(f: (int, int) -> int): int =
f(2, 2)
doAssert passTwoAndTwo((x, y) => x + y) == 4
type
Bot = object
call: proc (): string {.nosideEffect.}
var myBot = Bot()
myBot.call = () {.nosideEffect.} => "I'm a bot."
doAssert myBot.call() == "I'm a bot."
var
params = @[ident"auto"]
name = newEmptyNode()