Files
Nim/tests/arc/tmove_regression.nim
Andreas Rumpf 427ad17161 fixes #22001 (#22177)
* fixes #22001

* added test case
2023-06-27 22:42:48 +02:00

23 lines
569 B
Nim

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