Skip to content

Conversation

@jonludlam
Copy link
Member

See write-up of the problem here: https://jon.recoil.org/blog/2025/09/odoc-bugs.html

Claude's involvement in this fix was mostly in fleshing out the testing - in particular the 'edge_case' tests.

jonludlam and others added 7 commits February 2, 2026 18:33
… mismatch)

This test demonstrates that odoc crashes with Invalid_argument("List.fold_left2")
when a signature has a destructive type substitution followed by an include that
re-introduces a type with the same name but different arity.

The next commit will fix this crash.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…ferent arities

The fix applies inline TypeSubstitution items during include expansion. When
a module type containing a TypeSubstitution (like `type 'a t := unit`) is
included elsewhere, the substitution is now applied at that point rather than
being preserved as-is.

Key changes:
- Add `apply_inner_substs` function in tools.ml that processes TypeSubstitution,
  ModuleSubstitution, and ModuleTypeSubstitution items during include expansion
- Add `is_elidable_with_u` optimization to skip recompilation for pure signatures
- Add assertion for arity mismatch in type substitution to aid debugging
- Add `Subst.pp` for debugging substitution maps

This matches OCaml's behavior where destructive substitutions are applied to
produce a simplified signature when included.

Fixes ocaml#930, ocaml#1385

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The fix for ocaml#930 has revealed another pre-existing issue. The problem is
again that we've got more valid way to specify an item that ends up with
the same Identifier. In particular, when we `include` an explicit
`sig`, these items have the same parent as the sibling items of the include.
See the test for an example of the problem.
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.

1 participant