summary refs log tree commit diff stats
path: root/tests/arc/tmovebug.nim
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2022-10-01 16:46:51 +0200
committerGitHub <noreply@github.com>2022-10-01 16:46:51 +0200
commit8d47bf1822f7d7886ff62f6d14abe405f9f68ed7 (patch)
tree15f0c680c6bfcaeb47c17f21548c1dcb74507980 /tests/arc/tmovebug.nim
parentcfff454cf9852be9df2020c3a2d192caaa2f418a (diff)
downloadNim-8d47bf1822f7d7886ff62f6d14abe405f9f68ed7.tar.gz
new move analyser2 (#20471)
* produce better code for closure environment creation
* new 'first write' analysis; 
* scope based move analyser
* code cleanup

Co-authored-by: ringabout <43030857+ringabout@users.noreply.github.com>
Diffstat (limited to 'tests/arc/tmovebug.nim')
-rw-r--r--tests/arc/tmovebug.nim25
1 files changed, 23 insertions, 2 deletions
diff --git a/tests/arc/tmovebug.nim b/tests/arc/tmovebug.nim
index 002bd6796..8ad7c955c 100644
--- a/tests/arc/tmovebug.nim
+++ b/tests/arc/tmovebug.nim
@@ -93,6 +93,7 @@ destroy
 destroy
 destroy
 sink
+sink
 destroy
 copy
 (f: 1)
@@ -767,8 +768,7 @@ proc initC(): C =
   C(o: initO())
 
 proc pair(): tuple[a: C, b: C] =
-  result.a = initC() # <- when firstWrite tries to find this node to start its analysis it fails, because injectdestructors uses copyTree/shallowCopy
-  result.b = initC()
+  result = (a: initC(), b: initC())# <- when firstWrite tries to find this node to start its analysis it fails, because injectdestructors uses copyTree/shallowCopy
 
 discard pair()
 
@@ -818,3 +818,24 @@ proc atomicClosureOp =
 
 atomicClosureOp()
 
+
+template assertEq(a, b: untyped): untyped =
+  block:
+    let
+      aval = a
+      bval = b
+
+    if aval != bval:
+      quit "bug!"
+
+proc convoluted =
+  let _ = (;
+    var val1: string;
+    if true: val1 = "22"
+    true
+  )
+
+  assertEq val1, "22"
+  assertEq val1, "22"
+
+convoluted()