Skip to content

fix(menhir): infer through anonymous functors before OCaml 4.08 - #198

Closed
anmonteiro wants to merge 82 commits into
prototype/menhir-anonymous-opensfrom
fix/menhir-legacy-inference
Closed

anmonteiro wants to merge 82 commits into
prototype/menhir-anonymous-opensfrom
fix/menhir-legacy-inference

Conversation

@anmonteiro

Copy link
Copy Markdown
Owner

Stacked on #195. Use anonymous functor arguments for Menhir inference on OCaml 4.02–4.07, retaining anonymous opens on newer compilers. Related to ocaml#8989.

@anmonteiro
anmonteiro force-pushed the prototype/menhir-anonymous-opens branch 5 times, most recently from 50926cf to d7b08c3 Compare September 21, 2026 04:02
Alizter and others added 24 commits September 21, 2026 15:47
The table was being recreated for each call of create_with_paths making
the memoization useless. We move the Per_context wrapper to create,
where it can actually be keyed against the context name.

The caller of create_with_paths is pretty dubious, but I don't want to
touch the dev tools support at the moment, so I've left it alone.

Signed-off-by: Ali Caglayan <[email protected]>
The original motivation for this build was to avoid noise in the build
log when inspecting the observed invocations. Since, the test was
converted to use specific observations of the trace isntead. This means
this costly build is no longer relevant and cuts the runtime of the test
in half.

Signed-off-by: Ali Caglayan <[email protected]>
The table was being recreated for each call of create_with_paths making
the memoization useless. We move the Per_context wrapper to create,
where it can actually be keyed against the context name.

The caller of create_with_paths is pretty dubious, but I don't want to
touch the dev tools support at the moment, so I've left it alone.
…6453)

Pass only implementation dependencies through Menhir and interface
inference, removing the unused dictionary plumbing.

Extracted from #195; no behavior change.

---------

Signed-off-by: Antonio Nuno Monteiro <[email protected]>
Extend Menhir inference coverage for sibling dependencies, nested
scopes, subgroup interfaces, warning handling, and PPX name collisions.
Preserve the current failures for ocaml#8989.

Extracted from #195.

Signed-off-by: Antonio Nuno Monteiro <[email protected]>
Snapshot the generated Menhir inference query for the qualified
group-interface regression (ocaml#8989), preserving current main behavior.

Extracted from #195 so its alias-generation changes are
visible in the test diff.

Signed-off-by: Antonio Nuno Monteiro <[email protected]>
The original motivation for this build was to avoid noise in the build
log when inspecting the observed invocations. Since, the test was
converted to use specific observations of the trace isntead. This means
this costly build is no longer relevant and cuts the runtime of the test
in half.
The relocatable ocaml compiler relies on platform-specific heuristics to
find the compiler executable, which it then uses to locate the Stdlib.
When the relocatable ocaml compiler is managed as a regular package by
dune package management, we had been relying on behavior that is only
guaranteed on Linux to make up for a rule that did not specify its
dependency on the Stdlib. This allowed
ocaml#15642 to surface on macOS. The test
added here reproduces the error case by using a wrapper around the
compiler to reproduce the problematic Stdlib location logic.

Signed-off-by: Ali Caglayan <[email protected]>
Signed-off-by: Shon Feder <[email protected]>
Add the compiler's standard library directory as a hidden dependency of
the sandboxed `ocamlc -i` action that Menhir uses to infer interfaces.

This alone does not fix the reported failure, because the stdlib path is
classified as an external path, and the sandbox links only build paths
into the sandbox directory (see `Sandbox.link_deps`). Thus, the test
still shows "Unbound module Stdlib" after this commit.

Signed-off-by: Ali Caglayan <[email protected]>
Signed-off-by: Shon Feder <[email protected]>
The standard lib path is already constructed when creating the
`Lib_config.t` via `Lib_config.create`. But the current previous was
also constructing it a second time to derive the `Meta.builtins`.

This refactor simplifies the dataflow, and will enable us to avoid
brittle code duplication when we fix the classification of the stdlib's path
when the should be `Local`. Done in the following commit.

Signed-off-by: Shon Feder <[email protected]>
This will ensure that the path to the stdlib is correctly classified when
the relocatable compiler is provided as a normal package, thus requiring
a location inside the _build directory. Without classifying it correctly
we can fail to install the stdlib into sandboxes where it is needed.

Signed-off-by: Shon Feder <[email protected]>
A relocatable compiler that is installed under the workspace root but
outside _build (e.g., as with local opam switchs) will report a standard
library that `Path.Expert.try_localize_external` would try to map to a
source-tree path. Since sandboxed actions refuse source-tree dependencies,
the stdlib must stay external in that layout. Thus the conditional logic
introduced in the previous commit. This test would fails with an
internal error if the conditional guard on the reclassification were
removed, and it protects against regressions for future changes to that
bit of logic.

Signed-off-by: Shon Feder <[email protected]>
all the sibling functions use `proj` as the prefix

Signed-off-by: Shon Feder <[email protected]>
iirc, we used to initialize libraries into the `src/` directory (as is
done in dune itself). at some point this was moved into the more
consistent directory `lib/`, but the function name was not fixed accordingly.

Signed-off-by: Shon Feder <[email protected]>
The directory is already carried by the File.t

Signed-off-by: Shon Feder <[email protected]>
everything else in the file uses this path instead of `Dune_sexp.Atom.t`

Signed-off-by: Shon Feder <[email protected]>
rgrinberg and others added 26 commits September 28, 2026 00:05
…l#16444)

Record a dynamic action that restarts after cancellation, but whose
output remains at `ready` after a subsequent input change despite
another successful watch build. A fresh build produces the updated
value, `again`.

This PR contains only a cram regression recording current behavior; the
dependency-propagation fix is separate.

Related to ocaml#5681.

Signed-off-by: Rudi Grinberg <[email protected]>
…#16503)

Cover assigning sibling modules from one qualified subdirectory to
separate library stanzas.


Signed-off-by: Antonio Nuno Monteiro <[email protected]>
Reuse resolved private-library metadata for both project validation and
source-path construction.

Signed-off-by: Antonio Nuno Monteiro <[email protected]>
…16504)

Use the already-destructured compilation mode throughout Merlin
configuration processing.

Signed-off-by: Antonio Nuno Monteiro <[email protected]>
Document how mixed OCaml/Melange libraries build and install without
`melc`, and the cases that still require it.

Documents ocaml#15021 independently of ocaml#16501.

---------

Signed-off-by: Antonio Nuno Monteiro <[email protected]>
Track installed artifacts of lock-built packages and their dependencies
so `(deps (package ...))` rebuilds when they change.
Include whole packages reached through library dependencies and track
installed file changes.

Fixes ocaml#15511

The melange closure is not traversed.

Signed-off-by: Ali Caglayan <[email protected]>
Library-induced package dependencies make (package utop) also track
lambda-term. Nix compression leaves its dune-package manifest pointing
to missing uncompressed manpages.

Extend the existing utop workaround to lambda-term so the CI shell keeps
the installed files consistent with the manifest.

Signed-off-by: Ali Caglayan <[email protected]>
Use the existing package accessor for resolved package ownership instead
of keeping a separate package_owner API. Derive findlib namespaces
explicitly for callers that need library identity, preserving their
existing behavior.

Signed-off-by: Ali Caglayan <[email protected]>
Store the optional owner in Installed and Installed_private instead of a
separate Lib_info field. Preserve ownership resolution and public/private
behavior while updating status construction and matching.

Signed-off-by: Ali Caglayan <[email protected]>
Associate search paths with managed packages and resolve ownership in
findlib before passing it to META and dune-package decoding. Construct
installed library status with its owner instead of updating records later.

Keep unknown ownership in managed contexts and use the findlib package name
outside lock mode. Remove ownership setters and Lib.DB postprocessing.

Signed-off-by: Ali Caglayan <[email protected]>
Use Lib_info.package for workspace-library documentation compilation,
linking, package labels, output directories, and markdown package membership.
Dispatch library documentation by status so installed libraries aren't
treated as workspace targets. Keep the independent workspace-package lookup
unchanged.

Use status to identify unpackaged private libraries in the new odoc index,
preserving the existing name-based layout for other libraries. Apply the new
odoc package mask using library ownership. Pass the documentation package
explicitly when constructing library indexes, retaining the classified
metadata package for installed libraries and including it in the memo key.

Record library membership in documentation packages alongside location maps,
and use it for odoc dependencies instead of re-deriving package identity.

Signed-off-by: Ali Caglayan <[email protected]>
Collect public workspace ML-library packages directly from library status.
Keep private-plugin rejection and include flags for installed libraries.
Leave the Lib/Libexec-only layout dependency filtering unchanged to avoid
cycles when theories and plugins share a package.

Signed-off-by: Ali Caglayan <[email protected]>
Compare the package owners of a virtual library and its default
implementation. Keep implementation identity and privacy checks unchanged,
and clarify that installed package ownership may be unknown.

Signed-off-by: Ali Caglayan <[email protected]>
Use Lib_info.package to select the package-name flag for library
JavaScript emission.

Signed-off-by: Ali Caglayan <[email protected]>
Remove Lib_info.findlib_package now that all its callers have migrated.

Signed-off-by: Ali Caglayan <[email protected]>
Include whole packages reached through library dependencies and track
installed file changes. For packages in the lock directory, we have no
easy way of getting the libraries directly, so instead we use the direct
package closure which is already computed.

- Fixes ocaml#15511

When we start loading sources directly, this distinction with the old
"package universe" will no longer exist, so I think its fine for it to
work like this for now.
Share PPX library resolution between the two driver entry points.

Upstreams #148.

---------

Signed-off-by: Antonio Nuno Monteiro <[email protected]>
Hoist the invariant PPX lint command directory outside the module
callback.

Upstreams #166.

Signed-off-by: Antonio Nuno Monteiro <[email protected]>
Share the context lookup and profile used by inherited environment
stanzas.

Upstreams #164.

---------

Signed-off-by: Antonio Nuno Monteiro <[email protected]>
Pass the private inference interface through an anonymous functor
argument, retaining a unit functor for unpacking and generative applications.
Preserve generalized opens on newer compilers and logical dependency lookup.

Extend inference to supported compilers before OCaml 4.08, gating -opaque
on compiler support.

Follow up on ocaml#16464 and ocaml#16489 for ocaml#8989.

Signed-off-by: Antonio Nuno Monteiro <[email protected]>
@anmonteiro
anmonteiro force-pushed the fix/menhir-legacy-inference branch from 8985314 to 0e3729f Compare September 29, 2026 06:14
anmonteiro added a commit to ocaml/dune that referenced this pull request Sep 30, 2026
Extend the Menhir inference fix to OCaml 4.02.3–4.07 using anonymous
functor arguments around the private alias interface.

Follow-up to #16464 and #16489 for #8989; continues anmonteiro#198.

---------

Signed-off-by: Antonio Nuno Monteiro <[email protected]>
@anmonteiro

Copy link
Copy Markdown
Owner Author

Merged upstream as ocaml#16497.

@anmonteiro anmonteiro closed this Oct 2, 2026
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.

4 participants