@@ -54,20 +54,27 @@ when true:
54
54
55
55
proc `==` * [T: AnyPath](x, y: T): bool = eqImpl(x.string , y.string )
56
56
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
60
67
61
68
proc `/`*(base: AbsoluteDir; f: RelativeFile): AbsoluteFile =
62
- checkValid (base)
69
+ let base = postProcessBase (base)
63
70
assert(not isAbsolute(f.string ))
64
71
result = AbsoluteFile newStringOfCap(base.string .len + f.string .len)
65
72
var state = 0
66
73
addNormalizePath(base.string , result .string , state)
67
74
addNormalizePath(f.string , result .string , state)
68
75
69
76
proc `/`*(base: AbsoluteDir; f: RelativeDir): AbsoluteDir =
70
- checkValid (base)
77
+ let base = postProcessBase (base)
71
78
assert(not isAbsolute(f.string ))
72
79
result = AbsoluteDir newStringOfCap(base.string .len + f.string .len)
73
80
var state = 0
0 commit comments