Drop items without source text in Code_matcher - #648
Open
nmatschke wants to merge 1 commit into
Open
Conversation
nmatschke
requested review from
NathanReb,
ceastlund,
panglesd and
patricoferris
as code owners
July 31, 2026 18:57
NathanReb
reviewed
Aug 3, 2026
NathanReb
left a comment
Collaborator
There was a problem hiding this comment.
The change looks sane to me but I think it is worth a test!
Collaborator
|
Could you also rebase it on top of |
NathanReb
reviewed
Aug 3, 2026
| match_loop ~end_pos ~mismatch_handler ~expected ~source | ||
|
|
||
| (* [source] is supposed to be the list of items that follow the [@@deriving_inline] | ||
| item in the source file. That is not the case when the [@@deriving_inline] item is |
Collaborator
There was a problem hiding this comment.
This sounds a little bit odd, I think adding the ppx_template example here would make a bit more sense as otherwise, ppx generated deriving_inline nodes sounds a bit crazy and something we don't necessarily want to support.
Collaborator
|
Can you elaborate a bit more on |
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.
Code_matcherassumes that the items following an inline block's anchor areexactly the items that were parsed from the source file, and rewrites their source text
in place. That assumption breaks when the anchor is itself inside code generated by
another ppx. In particular,
ppx_templatewraps template-mangled definitions in(**/**)markers so odoc hides them, and those markers inherit the location of the node they were
generated from. So
expands to a
(**/**)item whose location is the wholetypedeclaration, and thecorrected code replaces the declaration with the derived signature instead of inserting
it after.
Fix this by dropping items that start before the end of the anchor item, since those
cannot correspond to source text following it.