-
Notifications
You must be signed in to change notification settings - Fork 179
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Backport Pexp_function from OCaml 5.2 #2544
Merged
Merged
Conversation
This file contains 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
TODO: Compiler libs shims are needed in Load_path and Builtin_attributes.
It already have some differences with upstream: - The special cases of a `fun` with only newtype arguments is no longer rewritten by `mkfunction`. - `(type a b)` is not desugared into `(type a) (type b)`
Rewrote the patterns 'Pexp_function cs' and 'Pexp_fun _ | Pexp_function _'. Remaining are 'Pexp_fun' and tweaking the formatting code.
Some patterns on `Pexp_fun _` were translated into `Pexp_function _`, which is too general.
The diff is due to inconsistent boxing in presence of a comment. The formatting of the `fun` now is the same as before if the comment was removed. The break behavior after the `->` is also different.
This is the normal formatting for argument lists. Previous version of ocamlformat would format the same if the argument list was 3 characters longer. The change is that the `->` keyword no longer exceed the margin.
Julow
added a commit
to Julow/ocamlformat
that referenced
this pull request
Oct 14, 2024
This will make the changes in ocaml-ppx#2544 easier to interpret.
Julow
added a commit
that referenced
this pull request
Oct 14, 2024
The diffs reported by test-branch are now very reasonable. |
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 a work in progress and is required for 5.2 compatibility.
The old
Pexp_function
andPexp_fun
are formatted in different ways in different contextes (eg. as an argument, in a let binding, after an infix operator, etc..), which are not easy to rewrite as the AST is very different.