Skip to content

Commit d5ccef7

Browse files
committed
fixup
1 parent 2810654 commit d5ccef7

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

compiler/pathutils.nim

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,20 +54,27 @@ when true:
5454

5555
proc `==`*[T: AnyPath](x, y: T): bool = eqImpl(x.string, y.string)
5656
57-
template checkValid(base: AbsoluteDir) =
58-
# empty paths should not mean `cwd`
59-
doAssert isAbsolute(base.string), base.string
57+
template postProcessBase(base: AbsoluteDir): untyped =
58+
# xxx: as argued here https://github.com/nim-lang/Nim/pull/10018#issuecomment-448192956
59+
# empty paths should not mean `cwd` so the correct behavior would be to throw
60+
# here and make sure `outDir` is always correctly initialized; for now
61+
# we simply preserve pre-existing external semantics and treat it as `cwd`
62+
when false:
63+
doAssert isAbsolute(base.string), base.string
64+
base
65+
else:
66+
if base.isEmpty: getCurrentDir().AbsoluteDir else: base
6067
6168
proc `/`*(base: AbsoluteDir; f: RelativeFile): AbsoluteFile =
62-
checkValid(base)
69+
let base = postProcessBase(base)
6370
assert(not isAbsolute(f.string))
6471
result = AbsoluteFile newStringOfCap(base.string.len + f.string.len)
6572
var state = 0
6673
addNormalizePath(base.string, result.string, state)
6774
addNormalizePath(f.string, result.string, state)
6875
6976
proc `/`*(base: AbsoluteDir; f: RelativeDir): AbsoluteDir =
70-
checkValid(base)
77+
let base = postProcessBase(base)
7178
assert(not isAbsolute(f.string))
7279
result = AbsoluteDir newStringOfCap(base.string.len + f.string.len)
7380
var state = 0

0 commit comments

Comments
 (0)