Fix canonical chain search - #1483
Open
jonludlam wants to merge 3 commits into
Open
Conversation
Libraries using Dune's wrapping with a hand-written top-level module get a canonical tag of Lib.M on every alias in the generated lib__.ml, whether or not lib.ml re-exports M. Where it doesn't, that path doesn't exist and references to M can't be resolved. A library can correct this from the module's own preamble, naming a path that does exist. This test shows that doesn't currently work: the reference picks up the corrected path, but the module it names loses its expansion, so no page is generated for it and the reference renders as plain text rather than a link. The expected output below records that broken behaviour. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
When resolving a canonical module path, handle_canonical_module_real walks the alias chain looking for a module marked with the path being resolved. The walk stopped at the first link carrying *any* canonical tag, so an unrelated tag masked a matching one further down. For the wrapped-library case in the previous commit, the bogus tag Dune put on the intermediate alias stopped the search before it reached the one the preamble corrected, and the canonical destination lost its expansion. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
`sed -i '1i ...'` is a GNU extension: BSD sed wants a backup suffix for -i and a different form of the insert command, so the test failed on macOS. Prepend the line with printf and cat instead. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This is an enabling PR - it allows people to fix the problems that happen when you write your own wrapper module that doesn't contain all of the library's modules. You should be able to put @canonical tags in the appropriate places after this.