-
Notifications
You must be signed in to change notification settings - Fork 469
test: document module name shadowing between stanza and library (#4572) #14031
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
Merged
Leonidas-from-XIV
merged 1 commit into
ocaml:main
from
robinbb:robinbb-issue-4572-shadowing
Apr 9, 2026
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
68 changes: 68 additions & 0 deletions
68
test/blackbox-tests/test-cases/per-module-lib-deps/module-name-shadowing.t
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| Test that when a stanza's internal module name shadows a library module name, | ||
| the internal module takes precedence. This validates that ocamldep-based | ||
| dependency filtering (which treats modules defined within the same stanza as | ||
| internal) correctly reflects the compiler's resolution order. | ||
|
|
||
| See: https://github.com/ocaml/dune/issues/4572 | ||
|
|
||
| $ cat > dune-project <<EOF | ||
| > (lang dune 3.0) | ||
| > EOF | ||
|
|
||
| --- Unwrapped library: internal module shadows library module --- | ||
|
|
||
| An unwrapped library exposes module Helper. The executable also has a module | ||
| named Helper. The internal module takes precedence — the library's Helper is | ||
| inaccessible. | ||
|
|
||
| $ mkdir unwrapped_lib | ||
| $ cat > unwrapped_lib/dune <<EOF | ||
| > (library | ||
| > (name unwrapped_lib) | ||
| > (wrapped false)) | ||
| > EOF | ||
|
|
||
| $ cat > unwrapped_lib/helper.ml <<EOF | ||
| > let lib_value = 42 | ||
| > EOF | ||
|
|
||
| $ cat > unwrapped_lib/helper.mli <<EOF | ||
| > val lib_value : int | ||
| > EOF | ||
|
|
||
| $ cat > dune <<EOF | ||
| > (executable | ||
| > (name main) | ||
| > (libraries unwrapped_lib)) | ||
| > EOF | ||
|
|
||
| $ cat > helper.ml <<EOF | ||
| > let local_value = 1 | ||
| > EOF | ||
|
|
||
| $ cat > main.ml <<EOF | ||
| > let () = print_int Helper.local_value | ||
| > EOF | ||
|
|
||
| The build succeeds using the internal Helper: | ||
|
|
||
| $ dune build ./main.exe | ||
|
|
||
| The dependencies of main.ml's native compilation show dune__exe__Helper | ||
| (the internal module), not unwrapped_lib's helper: | ||
|
|
||
| $ dune rules --deps _build/default/.main.eobjs/native/dune__exe__Main.cmx | grep dune__exe__Helper | ||
| (File (In_build_dir _build/default/.main.eobjs/byte/dune__exe__Helper.cmi)) | ||
|
|
||
| The library's Helper.lib_value is not accessible: | ||
|
|
||
| $ cat > main.ml <<EOF | ||
| > let () = print_int Helper.lib_value | ||
| > EOF | ||
|
|
||
| $ dune build ./main.exe | ||
| File "main.ml", line 1, characters 19-35: | ||
| 1 | let () = print_int Helper.lib_value | ||
| ^^^^^^^^^^^^^^^^ | ||
| Error: Unbound value Helper.lib_value | ||
| [1] | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.