summary refs log tree commit diff stats
path: root/tests/arc
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2023-06-27 22:42:48 +0200
committerGitHub <noreply@github.com>2023-06-27 22:42:48 +0200
commit427ad17161a19ecf8d0e2fc932064e18226210fa (patch)
tree970b0bfa657ecada1c87c0fdc5a6869d4a1576c6 /tests/arc
parent9616762cfe7a6d1607ba7d00e00537e9620aff50 (diff)
downloadNim-427ad17161a19ecf8d0e2fc932064e18226210fa.tar.gz
fixes #22001 (#22177)
* fixes #22001

* added test case
Diffstat (limited to 'tests/arc')
-rw-r--r--tests/arc/tmove_regression.nim22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/arc/tmove_regression.nim b/tests/arc/tmove_regression.nim
new file mode 100644
index 000000000..7d9a867c3
--- /dev/null
+++ b/tests/arc/tmove_regression.nim
@@ -0,0 +1,22 @@
+discard """
+  output: '''/1/2
+/1
+/
+'''
+""""
+
+# bug #22001
+
+import std / [os, strutils]
+
+proc finOp2(path, name: string): (string, File) = # Find & open FIRST `name`
+  var current = path
+  while true:
+    if current.isRootDir: break # <- current=="" => current.isRootDir
+    current = current.parentDir
+    let dir = current
+    echo dir.replace('\\', '/')  # Commenting out try/except below hides bug
+    try: result[0] = dir/name; result[1] = open(result[0]); return
+    except CatchableError: discard
+
+discard finOp2("/1/2/3", "4")  # All same if this->inside a proc