Skip to content

Commit 1626a1f

Browse files
authored
fix(stdlib): Error when relativeTo used on relative source and absolute dest (#2054)
1 parent b6843ce commit 1626a1f

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

compiler/test/stdlib/path.test.gr

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,11 @@ let relativeToTests = [
253253
dest: "./a.txt",
254254
result: Err(Path.Incompatible(Path.DifferentBases)),
255255
},
256+
{
257+
source: "./a.txt",
258+
dest: "/bin",
259+
result: Err(Path.Incompatible(Path.DifferentBases)),
260+
},
256261
]
257262

258263
List.forEach(({ source, dest, result }) => {

stdlib/path.gr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,7 @@ provide let relativeTo = (source, dest) => {
571571
let pathInfo2 = pathInfo(dest)
572572
let (base2, _, _) = pathInfo2
573573
match ((base1, base2)) {
574-
(Abs(_), Rel(_)) | (Abs(_), Rel(_)) => Err(Incompatible(DifferentBases)),
574+
(Abs(_), Rel(_)) | (Rel(_), Abs(_)) => Err(Incompatible(DifferentBases)),
575575
_ => Result.map(toPath, relativeToHelper(pathInfo1, pathInfo2)),
576576
}
577577
}

0 commit comments

Comments
 (0)