aboutsummaryrefslogtreecommitdiff
path: root/src/checker.cpp
diff options
context:
space:
mode:
authorJeroen van Rijn <Kelimion@users.noreply.github.com>2025-04-27 14:32:26 +0200
committerJeroen van Rijn <Kelimion@users.noreply.github.com>2025-04-27 14:32:26 +0200
commitd463aba7d110d08ff9cfdecd66098c99c0747b78 (patch)
treed03a423dce072fe17cc1a922ba460900cd51d7b0 /src/checker.cpp
parent7d4c3d23e6156c1b4be1f91e6d18e51a8e9814f0 (diff)
Warn if someone imports the same case-folded path twice
Diffstat (limited to 'src/checker.cpp')
-rw-r--r--src/checker.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/checker.cpp b/src/checker.cpp
index 5a5ec9706..038c5aa1a 100644
--- a/src/checker.cpp
+++ b/src/checker.cpp
@@ -6423,6 +6423,19 @@ gb_internal void check_unique_package_names(Checker *c) {
"\tThere is no relation between a package name and the directory that contains it, so they can be completely different\n"
"\tA package name is required for link name prefixing to have a consistent ABI\n");
error_line("%s found at previous location\n", token_pos_to_string(ast_token(prev).pos));
+
+ // NOTE(Jeroen): Check if the conflicting imports are the same case-folded directory
+ // See https://github.com/odin-lang/Odin/issues/5080
+ #if defined(GB_SYSTEM_WINDOWS)
+ String dir_a = pkg->files[0]->directory;
+ String dir_b = (*found)->files[0]->directory;
+
+ if (str_eq_ignore_case(dir_a, dir_b)) {
+ error_line("\tRemember that Windows case-folds paths, and so %.*s and %.*s are the same directory.\n", LIT(dir_a), LIT(dir_b));
+ // Could also perform a FS lookup to check which of the two is the actual directory and suggest it, but this should be enough.
+ }
+ #endif
+
end_error_block();
}
}