Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(stdlib): Error when relativeTo used on relative source and absolute dest #2054

Merged
merged 1 commit into from Mar 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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