fix: only generate @ocaml-index alias for merlin-enabled contexts#14137
Merged
rgrinberg merged 2 commits intoocaml:mainfrom Apr 11, 2026
Merged
Conversation
cede35d to
cf1865b
Compare
rgrinberg
approved these changes
Apr 11, 2026
Member
rgrinberg
left a comment
There was a problem hiding this comment.
A change log entry would be appropriate
voodoos
approved these changes
Apr 11, 2026
Collaborator
voodoos
left a comment
There was a problem hiding this comment.
Looks good to me, just a small style nitpick that you can ignore.
b4035d4 to
126f418
Compare
@ocaml-index indexes stanzas in all contexts, including alternative contexts where some libraries may be disabled. This causes errors when a stanza in an alt context depends on a library only enabled in the default context. Test 1 shows the failure: @ocaml-index errors trying to index the alt context where defaultlib is hidden by enabled_if. Test 2 confirms that (enabled_if false) libraries are already correctly excluded from indexing within a single context. Signed-off-by: Robin Bate Boerop <me@robinbb.com>
…aml#12007) @ocaml-index was generating indexing rules for all contexts, including alternative contexts where some libraries may be disabled. This caused errors when a stanza in an alt context depended on a library only available in the default context. Fix by guarding project_rule with Context.merlin, so the @ocaml-index alias is only created for the context that has merlin support enabled (typically the default context). Signed-off-by: Robin Bate Boerop <me@robinbb.com>
126f418 to
fe71a78
Compare
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.
Summary
Partially addresses #12007.
@ocaml-indexwas generating indexing rules for all contexts, including alternative contexts where some libraries may be disabled byenabled_if. This caused build errors when a stanza in an alt context depended on a library only available in the default context:The fix guards
Ocaml_index.project_rulewithContext.merlin, so the@ocaml-indexalias is only created for the context that has merlin support enabled (typically the default context). This matches the intent of the indexing feature, which exists to support editor tooling in the primary development context.The second part of #12007 (indexing unreferenced files not linked by any stanza) is not addressed here, as it shares a root cause with #9724 and requires deeper changes to how
context_indexescollects stanzas.