summary refs log tree commit diff stats
path: root/tests/arc/tmovebug.nim
diff options
context:
space:
mode:
Diffstat (limited to 'tests/arc/tmovebug.nim')
-rw-r--r--tests/arc/tmovebug.nim33
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/arc/tmovebug.nim b/tests/arc/tmovebug.nim
index 3b7a7c5df..61105b44e 100644
--- a/tests/arc/tmovebug.nim
+++ b/tests/arc/tmovebug.nim
@@ -70,6 +70,9 @@ king
 hi
 try
 bye
+()
+()
+()
 '''
 """
 
@@ -524,3 +527,33 @@ proc getScope2(): string =
     "else"
 
 echo getScope2()
+
+
+#--------------------------------------------------------------------
+#bug  #15609
+
+type
+  Wrapper = object
+    discard
+
+proc newWrapper(): ref Wrapper =
+  new(result)
+  result
+
+
+proc newWrapper2(a: int): ref Wrapper =
+  new(result)
+  if a > 0:
+    result
+  else:
+    new(Wrapper)
+
+
+let w1 = newWrapper()
+echo $w1[]
+
+let w2 = newWrapper2(1)
+echo $w2[]
+
+let w3 = newWrapper2(-1)
+echo $w3[]
\ No newline at end of file