From 839ec1395db347ce0f74f8e0f66edbf20c6fc0fc Mon Sep 17 00:00:00 2001 From: flywind <43030857+xflywind@users.noreply.github.com> Date: Fri, 6 Nov 2020 18:42:43 +0800 Subject: [PATCH] follow #11707(add pragmas examples for =>) (#15863) (cherry picked from commit 9fd67958b97c0254c3b4d8762a7003e317ec21bb) --- lib/pure/sugar.nim | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/pure/sugar.nim b/lib/pure/sugar.nim index d0f85ad171..46dbb1ecee 100644 --- a/lib/pure/sugar.nim +++ b/lib/pure/sugar.nim @@ -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()