Skip to content

Commit

Permalink
fix(stdlib): Error when relativeTo used on relative source and abso…
Browse files Browse the repository at this point in the history
…lute dest (#2054)
  • Loading branch information
alex-snezhko committed Mar 3, 2024
1 parent b6843ce commit 1626a1f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions compiler/test/stdlib/path.test.gr
Expand Up @@ -253,6 +253,11 @@ let relativeToTests = [
dest: "./a.txt",
result: Err(Path.Incompatible(Path.DifferentBases)),
},
{
source: "./a.txt",
dest: "/bin",
result: Err(Path.Incompatible(Path.DifferentBases)),
},
]

List.forEach(({ source, dest, result }) => {
Expand Down
2 changes: 1 addition & 1 deletion stdlib/path.gr
Expand Up @@ -571,7 +571,7 @@ provide let relativeTo = (source, dest) => {
let pathInfo2 = pathInfo(dest)
let (base2, _, _) = pathInfo2
match ((base1, base2)) {
(Abs(_), Rel(_)) | (Abs(_), Rel(_)) => Err(Incompatible(DifferentBases)),
(Abs(_), Rel(_)) | (Rel(_), Abs(_)) => Err(Incompatible(DifferentBases)),
_ => Result.map(toPath, relativeToHelper(pathInfo1, pathInfo2)),
}
}
Expand Down

0 comments on commit 1626a1f

Please sign in to comment.