Skip to content

Fix Merlin hidden includes for libraries with private modules - #16629

Merged
rgrinberg merged 1 commit into
ocaml:mainfrom
DirkEmmett:fix/16531-merlin-hidden-includes
Nov 7, 2026
Merged

rgrinberg merged 1 commit into
ocaml:mainfrom
DirkEmmett:fix/16531-merlin-hidden-includes

Conversation

@DirkEmmett

@DirkEmmett DirkEmmett commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Depends on #16848 (tests-only; merge first).

Public aliases backed by private modules can build successfully but fail in Merlin because Dune omits their hidden CMI directory. Add the missing BH paths for local direct and hidden transitive dependencies, preserving annotation paths and existing visibility.

The test setup is submitted separately in #16848; this branch builds on that commit and changes the expectations to require successful alias typing. Until the tests PR lands, GitHub's main-based diff includes the shared test commit. Fix-only comparison.

Fixes #16531.

Validation: dune build @check @fmt @runtest passed locally on both branches with OCaml 5.5.0 and ppxlib 0.39.0. Actual Merlin 5.8.1 queries confirmed that the tests-only branch retains the alias error and this fix restores typing, completion, and navigation while direct private names remain inaccessible.

DirkEmmett added a commit to DirkEmmett/dune that referenced this pull request Oct 17, 2026
Document the editor behavior restored by ocaml#16629.

Signed-off-by: Dirk Emmett <[email protected]>
@Alizter Alizter self-assigned this Oct 21, 2026
@Alizter
Alizter self-requested a review October 26, 2026 13:52
@Alizter

Alizter commented Oct 26, 2026

Copy link
Copy Markdown
Collaborator

@DirkEmmett Could you submit the tests in a separate PR?

@DirkEmmett

Copy link
Copy Markdown
Contributor Author

@Alizter Split the tests into #16848. That PR records the current bug without changing production code.

This fix builds on the test commit and updates the expectations. Fix-only comparison. The tests PR should land first.

Both branches pass dune build @check @fmt @runtest locally. Could you also apply the no changelog label to #16848? It is tests-only, and I do not have permission to set repository labels.

Alizter added a commit that referenced this pull request Oct 29, 2026
Split out from #16629 as requested in
#16629 (comment).

Extends the existing #16531 reproduction to hidden transitive
dependencies. The test records the missing hidden CMI path, demonstrates
that adding it with `-H` restores alias typing, and checks that direct
private-module and hidden-dependency names remain inaccessible. No
production code changes.

Validation: `dune build @check @fmt @runtest` passed locally with OCaml
5.5.0 and ppxlib 0.39.0. A real Merlin smoke check confirmed that this
tests-only branch preserves the reported alias error.

Intended to land before the fix in #16629. Tests only; no changelog
entry is needed. Please apply the `no changelog` label.
Reuse the local byte directories as hidden Merlin CMI paths on supported OCaml compilers. Preserve annotation paths and direct-name visibility, and require direct and hidden-transitive aliases to type using generated paths only.

Fixes ocaml#16531.

Signed-off-by: Dirk Emmett <[email protected]>
@rgrinberg
rgrinberg force-pushed the fix/16531-merlin-hidden-includes branch from f3b881a to 7deeb04 Compare November 6, 2026 16:40
@anmonteiro
anmonteiro self-requested a review November 6, 2026 17:19
@Alizter Alizter removed their assignment Nov 6, 2026
and+ indexes, indexes_digest = Ocaml_index.context_indexes context ~for_
and+ use_hidden_includes =
match for_ with
| Melange -> Action_builder.return false

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@rgrinberg
rgrinberg merged commit 2dc2d35 into ocaml:main Nov 7, 2026
38 checks passed
@Alizter Alizter added this to the 3.26.0 milestone Nov 7, 2026
anmonteiro added a commit that referenced this pull request Nov 10, 2026
…#16937)

Demonstrate that private wrapper aliases compile without sandboxing but
fail in a fresh copy sandbox because the private CMI is unavailable.
Found while checking the Melange counterparts of #16629.

01a12d8e-c091-7010-b0cd-3fdc40400e80

---------

Signed-off-by: Antonio Nuno Monteiro <[email protected]>
anmonteiro added a commit that referenced this pull request Nov 10, 2026
…6931)

Demonstrate that public aliases of private Melange modules fail to
compile, including in a fresh copy sandbox. Related to #16629.

01a12d8e-c091-7010-b0cd-3fdc40400e80

---------

Signed-off-by: Antonio Nuno Monteiro <[email protected]>
anmonteiro added a commit that referenced this pull request Nov 10, 2026
…#16932)

Demonstrate missing private CMIs through hidden transitive Melange
dependencies, while checking that direct dependency names remain hidden.
Related to #16629.

01a12d8e-c091-7010-b0cd-3fdc40400e80

---------

Signed-off-by: Antonio Nuno Monteiro <[email protected]>
anmonteiro added a commit that referenced this pull request Nov 10, 2026
Demonstrate the difference between OCaml and Melange when resolving a
private module through its generated wrapper alias. Related to #16629.

01a12d8e-c091-7010-b0cd-3fdc40400e80

---------

Signed-off-by: Antonio Nuno Monteiro <[email protected]>
anmonteiro added a commit that referenced this pull request Nov 10, 2026
…16934)

Demonstrate that aliases into installed private libraries work in OCaml
but fail in Melange, while direct private references remain unavailable.
Related to #16629.

01a12d8e-c091-7010-b0cd-3fdc40400e80

---------

Signed-off-by: Antonio Nuno Monteiro <[email protected]>
anmonteiro added a commit that referenced this pull request Nov 16, 2026
Demonstrate the missing hidden CMI directory in Merlin configurations for direct Melange dependencies with private modules. Related to #16629; regression for #16942.

01a12d8e-c091-7010-b0cd-3fdc40400e80

Signed-off-by: Antonio Nuno Monteiro <[email protected]>
anmonteiro added a commit that referenced this pull request Nov 16, 2026
Demonstrate the missing private CMI directory in Merlin configurations for hidden transitive Melange dependencies. Related to #16629; regression for #16942.

01a12d8e-c091-7010-b0cd-3fdc40400e80

Signed-off-by: Antonio Nuno Monteiro <[email protected]>
anmonteiro added a commit that referenced this pull request Nov 16, 2026
Include private Melange dependency interfaces as hidden Merlin paths, matching the OCaml behavior from #16629.

Fixes the merged regression tests from #16935 and #16936.

01a12d8e-c091-7010-b0cd-3fdc40400e80

Signed-off-by: Antonio Nuno Monteiro <[email protected]>
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.

Merlin configuration omits the hidden include (-H) of a library with private modules

3 participants