summary refs log tree commit diff stats
path: root/lib
diff options
context:
space:
mode:
authorflywind <43030857+xflywind@users.noreply.github.com>2020-11-06 18:42:43 +0800
committerGitHub <noreply@github.com>2020-11-06 11:42:43 +0100
commit9fd67958b97c0254c3b4d8762a7003e317ec21bb (patch)
treee296a007d3b70627fae630db12101bfb04a0274c /lib
parent218ff27b70c05340069d262204f785290467aa00 (diff)
downloadNim-9fd67958b97c0254c3b4d8762a7003e317ec21bb.tar.gz
follow #11707(add pragmas examples for =>) (#15863)
Diffstat (limited to 'lib')
-rw-r--r--lib/pure/sugar.nim10
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/pure/sugar.nim b/lib/pure/sugar.nim
index d0f85ad17..46dbb1ece 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()