summary refs log tree commit diff stats
path: root/tests/arc/tmove_regression.nim
blob: 7d9a867c3916d41786262666d1d8313c050d7900 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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