Skip to content

test: document module name shadowing between stanza and library (#4572)#14031

Merged
Leonidas-from-XIV merged 1 commit intoocaml:mainfrom
robinbb:robinbb-issue-4572-shadowing
Apr 9, 2026
Merged

test: document module name shadowing between stanza and library (#4572)#14031
Leonidas-from-XIV merged 1 commit intoocaml:mainfrom
robinbb:robinbb-issue-4572-shadowing

Conversation

@robinbb
Copy link
Copy Markdown
Contributor

@robinbb robinbb commented Apr 3, 2026

Add a test documenting module name shadowing behavior between a stanza's
internal modules and an unwrapped library dependency.

When an executable has a module Helper and also depends on an unwrapped
library that exposes a module Helper, the internal module takes precedence:
the build succeeds using the internal module, and the library's Helper is
inaccessible (Unbound value).

This behavior is relevant to #4572 (finer dependency analysis between
libraries), where ocamldep output is used to determine which libraries a
module references. Since the compiler resolves shadowed names to the internal
module, ocamldep reports the internal name — filtering it out as
stanza-internal (rather than treating it as a library reference) is correct.

Ref: #4572

@robinbb robinbb marked this pull request as ready for review April 3, 2026 23:08
@robinbb
Copy link
Copy Markdown
Contributor Author

robinbb commented Apr 3, 2026

@rgrinberg This PR is in response to your leading question on PR #14021 about shadowing.

@robinbb robinbb force-pushed the robinbb-issue-4572-shadowing branch 4 times, most recently from 2fba4cc to 8ddbad3 Compare April 6, 2026 15:41
@Alizter Alizter requested review from Alizter and Copilot April 6, 2026 16:29
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a new blackbox test suite under per-module-lib-deps/ to document current (coarse) recompilation behavior in Dune’s dependency analysis, plus a focused test documenting module-name shadowing between stanza-internal modules and unwrapped library modules (relevant to ocamldep-based filtering for #4572).

Changes:

  • Add baseline tests showing that changes in a dependency (direct, transitive, virtual, wrapped/unwrapped, wrapped-compat) currently trigger broader recompilation than “per-module” would imply.
  • Add a test that demonstrates stanza-internal module name shadowing takes precedence over an unwrapped library module of the same name.
  • Add an opaque-mode test capturing the difference between release (opaque=false) and dev (opaque=true) recompilation behavior for implementation-only changes.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
test/blackbox-tests/test-cases/per-module-lib-deps/basic-wrapped.t Baseline for wrapped library interface-change causing recompilation of unrelated executable modules.
test/blackbox-tests/test-cases/per-module-lib-deps/lib-to-lib-unwrapped.t Baseline for coarse recompilation when an unwrapped library depends on an unwrapped multi-module library.
test/blackbox-tests/test-cases/per-module-lib-deps/lib-to-lib-wrapped.t Baseline for coarse recompilation in a wrapped library-to-library dependency.
test/blackbox-tests/test-cases/per-module-lib-deps/module-name-shadowing.t Documents module name shadowing behavior between an executable’s internal module and an unwrapped library module.
test/blackbox-tests/test-cases/per-module-lib-deps/multiple-libraries.t Baseline for coarse recompilation when an executable depends on multiple libraries and only one changes.
test/blackbox-tests/test-cases/per-module-lib-deps/opaque.t Captures opaque-mode impact on recompilation for implementation-only changes (release vs dev profile).
test/blackbox-tests/test-cases/per-module-lib-deps/transitive.t Baseline for recompilation driven by transitive dependency changes even for independent modules.
test/blackbox-tests/test-cases/per-module-lib-deps/unwrapped.t Baseline for coarse recompilation when a single module in an unwrapped library changes.
test/blackbox-tests/test-cases/per-module-lib-deps/virtual-library.t Baseline for recompilation behavior when a virtual library’s interface changes.
test/blackbox-tests/test-cases/per-module-lib-deps/wrapped-compat.t Baseline for recompilation behavior involving wrapped-compat modules from (wrapped (transition ...)).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Alizter
Copy link
Copy Markdown
Collaborator

Alizter commented Apr 6, 2026

The copilot review feature of GitHub is useful for catching silly mistakes, but when there aren't any it can spew nonsense. Feel free to ignore it and pick out only what is useful.

@robinbb
Copy link
Copy Markdown
Contributor Author

robinbb commented Apr 6, 2026

The copilot review feature of GitHub is useful for catching silly mistakes, but when there aren't any it can spew nonsense. Feel free to ignore it and pick out only what is useful.

Okay, makes sense. Thanks for helping!

@robinbb robinbb force-pushed the robinbb-issue-4572-shadowing branch 4 times, most recently from 7a7293a to 386b933 Compare April 7, 2026 17:52
@robinbb robinbb force-pushed the robinbb-issue-4572-shadowing branch from 3f4a328 to 3d1f5ad Compare April 8, 2026 14:35
@robinbb
Copy link
Copy Markdown
Contributor Author

robinbb commented Apr 8, 2026

@Leonidas-from-XIV Addressed your concerns. Please have a look.

Copy link
Copy Markdown
Collaborator

@Leonidas-from-XIV Leonidas-from-XIV left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have one more concern that I probably missed in the last review.

When an internal module name shadows an unwrapped library's module name,
the internal module takes precedence and the library's module is
inaccessible. This means ocamldep will report the internal module, not
the library's, so dependency filtering that treats stanza-internal names
as non-library references is correct.

Signed-off-by: Robin Bate Boerop <me@robinbb.com>
@robinbb robinbb force-pushed the robinbb-issue-4572-shadowing branch from 3d1f5ad to aae05cd Compare April 8, 2026 23:10
@robinbb
Copy link
Copy Markdown
Contributor Author

robinbb commented Apr 8, 2026

@Leonidas-from-XIV Thanks for your review. Much appreciated. I have addressed your concerns. Care to review again (and merge if merited)?

Copy link
Copy Markdown
Collaborator

@Leonidas-from-XIV Leonidas-from-XIV left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Leonidas-from-XIV Leonidas-from-XIV merged commit b4050f2 into ocaml:main Apr 9, 2026
30 checks passed
@robinbb robinbb deleted the robinbb-issue-4572-shadowing branch April 9, 2026 11:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants