summary refs log tree commit diff stats
path: root/tests/closure
diff options
context:
space:
mode:
authorClyybber <darkmine956@gmail.com>2020-02-15 19:53:40 +0100
committerGitHub <noreply@github.com>2020-02-15 19:53:40 +0100
commitf3eb0a5970ff0b9ec5ed8b95551c79cea395e279 (patch)
tree031ce9719cdb544ea51ddb08b4b686663ab34906 /tests/closure
parent5bf571f061d53d35aab727f420afd9f415987723 (diff)
downloadNim-f3eb0a5970ff0b9ec5ed8b95551c79cea395e279.tar.gz
capture macro now accepts variables of different types (#13356)
* Capture macro can now accept variables of different types

* Add test

* Update examples

* Use let instead of var
Diffstat (limited to 'tests/closure')
-rw-r--r--tests/closure/tcapture.nim14
1 files changed, 11 insertions, 3 deletions
diff --git a/tests/closure/tcapture.nim b/tests/closure/tcapture.nim
index ff3490f07..dafc44739 100644
--- a/tests/closure/tcapture.nim
+++ b/tests/closure/tcapture.nim
@@ -2,7 +2,9 @@ discard """
   output: '''
 to be, or not to be
 (v: 1)
+(w: -1)
 (v: 1)
+(w: -1)
 '''
   joinable: false
 """
@@ -14,13 +16,19 @@ var l = m.mapIt(capture([it], proc (s: string): string = it(s)))
 let r = l.mapIt(it("be"))
 echo r[0] & ", or " & r[1]
 
-type O = object
-  v: int
+type
+  O = object
+    v: int
+  U = object
+    w: int
 var o = O(v: 1)
+var u = U(w: -1)
 var execute: proc()
-capture [o]:
+capture o, u:
   execute = proc() =
     echo o
+    echo u
 execute()
 o.v = -1
+u.w = 1
 execute()