Repository navigation
Fix JSX elements closed directly before |] and } - #17
Merged
Merged
Conversation
Port of ocaml-mlx/mlx#46 to both vendored parsers: a dedicated `>|]` lexer rule backtracks to give the `>` back so `|]` lexes as BARRBRACKET, and `>}` is stolen the same way with the object-override grammar compensating by closing with GREATER RBRACE. Also fix Pexp_override printing to keep parentheses around a bare `>` comparison used as a field value (any field, not just the last one): dropping them produced output that fails the reparse self-check, since an unparenthesized `a > b` in an override field list is ambiguous with the closing `>` under the new two-token close. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
`(x : <m : int>)` failed to parse because `<m` lexes as the JSX element-open token even in type position, where JSX can never occur. Both vendored grammars now accept the fused token as `<` plus the first method label: field/field_semi are parameterized over the label symbol, and object_type gains a meth_list_jsx alternative fed by an inline jsx_first_label rule. Lexers untouched; spaced object types, `< .. >`, and expression JSX are covered by regression tests. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Member
Author
|
Second commit: same object-type fix as ocaml-mlx/mlx#46 — |
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
davesnx
approved these changes
Sep 16, 2026
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.
Port of ocaml-mlx/mlx#46 to the formatter's two vendored parsers, fixing:
Same mechanics as the mlx PR: a
>|]lexer rule gives the>back so|]lexes asBARRBRACKET;>}is stolen the same way, with the object-override productions closing viaGREATER RBRACEinstead of the singleGREATERRBRACEtoken ({< x = 2 >}keeps working in both spacings). Menhir reports zero conflicts before and after in both grammars (--strict --explain); the deadGREATERRBRACEtoken joins the--unused-tokenlists since this fork builds menhir with--strict.Additional formatter fix the mlx repo didn't need:
Pexp_overrideprinting now keeps parentheses around a bare>comparison used as a field value — dropping them (previous behavior) produces output that no longer reparses under the two-token close. Testing here also showed the known limitation from ocaml-mlx/mlx#46 is broader than the PR states: an unparenthesizeda > bin any override field position (not just the last) needs parens now, in both repos.Tests: array/list/record/
with-update JSX closes, override both spacings, paren-preserving comparison cases,>|operator sanity, all idempotent; the full ocamlformat suite passes with no changes to pre-existing{< ... >}tests. CHANGES.md entry included.🤖 Generated with Claude Code