summary refs log tree commit diff stats
path: root/tests/arc
diff options
context:
space:
mode:
authorringabout <43030857+ringabout@users.noreply.github.com>2024-08-20 17:57:47 +0800
committerGitHub <noreply@github.com>2024-08-20 11:57:47 +0200
commit26107e931cb846647bae3a7335d2ac1993dc4386 (patch)
treee6ccfe49cb179a3ee737b06b84c2118fa2867914 /tests/arc
parent34719cad9d95b9a13fbbc5bfb9e5e06662a8c6ed (diff)
downloadNim-26107e931cb846647bae3a7335d2ac1993dc4386.tar.gz
fixes #23973; fixes #23974; Memory corruption with lent and ORC (#23981)
fixes #23973;
fixes #23974
Diffstat (limited to 'tests/arc')
-rw-r--r--tests/arc/tarcmisc.nim31
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/arc/tarcmisc.nim b/tests/arc/tarcmisc.nim
index 58b4aa7c0..49f1b80ce 100644
--- a/tests/arc/tarcmisc.nim
+++ b/tests/arc/tarcmisc.nim
@@ -32,6 +32,7 @@ true
 copying
 123
 42
+@["", "d", ""]
 ok
 destroying variable: 20
 destroying variable: 10
@@ -789,3 +790,33 @@ block: # bug #23907
 
   doAssert callback(Thingy(value: 123)) == 123
 
+import std/strutils
+
+block: # bug #23974
+  func g(e: seq[string]): lent seq[string] = result = e
+  proc k(f: string): seq[string] = f.split("/")
+  proc n() =
+    const r = "/d/"
+    let t =
+      if true:
+        k(r).g()
+      else:
+        k("/" & r).g()
+    echo t
+
+  n()
+
+block: # bug #23973
+  func g(e: seq[string]): lent seq[string] = result = e
+  proc k(f: string): seq[string] = f.split("/")
+  proc n() =
+    const r = "/test/empty"  # or "/test/empty/1"
+    let a = k(r).g()
+    let t =
+      if true:
+        k(r).g()
+      else:
+        k("/" & r).g()   # or raiseAssert ""
+    doAssert t == a
+
+  n()