Skip to content
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 164 commits into from
Oct 14, 2024
Merged

Conversation

Julow
Copy link
Collaborator

@Julow Julow commented Apr 18, 2024

This is a work in progress and is required for 5.2 compatibility.

The old Pexp_function and Pexp_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.

gpetiot and others added 30 commits January 23, 2024 11:05
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 Julow mentioned this pull request Oct 14, 2024
Julow added a commit that referenced this pull request Oct 14, 2024
This will make the changes in #2544 easier to interpret.
@Julow Julow marked this pull request as ready for review October 14, 2024 15:08
@Julow
Copy link
Collaborator Author

Julow commented Oct 14, 2024

The diffs reported by test-branch are now very reasonable. +495 -406 on a total of a million line of code, most of which appear as bug fixes.
Let's merge !

@Julow Julow merged commit 3386dca into ocaml-ppx:main Oct 14, 2024
9 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants