Fix missing open line between multi-line let-binding with poly-typexpr#1372
Merged
Fix missing open line between multi-line let-binding with poly-typexpr#1372
Conversation
jberdine
commented
May 22, 2020
gpetiot
approved these changes
Jun 12, 2020
Collaborator
gpetiot
left a comment
There was a problem hiding this comment.
Looks good to me, thanks! Can you add a test for that, and a changelog entry, and then we can merge.
Collaborator
Author
|
There is a test in the PR description that I tried and failed to understand how to add to the test suite as it currently is set up. Where / how should that be added, considering that |
Collaborator
|
I think you can do the same thing as for |
The is_simple check for let bindings only considers the location of the body exp. This location happens to usually be large enough. But for one of a group of let bindings which has an explicit polymorphic type constraint, the location of the body exp contains only the body, and does not include the location of the pattern. This means that cases such as: ```ocaml [@@@ocamlformat "let-binding-spacing=compact"] let f x = x and g : 'a. (_ -> _ -> _ -> 'a) -> _ -> _ -> _ -> 'a = fun h a b -> h (i a) (i b) (i c) ``` get misformatted since `g` is misidentified as being a one-liner, and the open line between `f` and `g` gets removed. This patch fixes this by using the location of the entire let-binding instead of the body expression.
Collaborator
Author
|
@gpetiot could you check the added test? |
gpetiot
approved these changes
Jun 26, 2020
Collaborator
gpetiot
left a comment
There was a problem hiding this comment.
The tests look good, I added the results for other values of this option.
emillon
added a commit
to emillon/opam-repository
that referenced
this pull request
Aug 6, 2020
CHANGES:
#### Changes
+ Do not break inline elements such as `{i blah}` in docstrings (ocaml-ppx/ocamlformat#1346, @jberdine)
+ Distinguish hash-getter from hash-comparison infix operators. Operators of the form `#**#` or `#**.` where `**` can be 0 or more operator chars are considered getter operators and are not surrounded by spaces, as opposed to regular infix operators (ocaml-ppx/ocamlformat#1376, @gpetiot)
+ Type constraint on return type of functions is now always printed before the function body (ocaml-ppx/ocamlformat#1381, ocaml-ppx/ocamlformat#1397, @gpetiot)
#### Bug fixes
+ Restore previous functionality for pre-post extension points (ocaml-ppx/ocamlformat#1342, @jberdine)
+ Fix extra break before `function` body of a `fun` (ocaml-ppx/ocamlformat#1343, @jberdine)
Indent further args of anonymous functions (ocaml-ppx/ocamlformat#1440, @gpetiot)
+ Do not clear the emacs `*compilation*` buffer on successful reformat (ocaml-ppx/ocamlformat#1350, @jberdine)
+ Fix disabling with attributes on OCaml < 4.08 (ocaml-ppx/ocamlformat#1322, @emillon)
+ Preserve unwrapped comments by not adding artificial breaks when `wrap-comments=false` and `ocp-indent-compat=true` are set to avoid interfering with ocp-indent indentation. (ocaml-ppx/ocamlformat#1352, @gpetiot)
+ Break long literal strings at the margin (ocaml-ppx/ocamlformat#1367, @gpetiot)
+ Break after a multiline argument in an argument list (ocaml-ppx/ocamlformat#1360, @gpetiot)
+ Remove unnecessary parens around object (ocaml-ppx/ocamlformat#1379, @gpetiot)
+ Fix placement of comments on constants (ocaml-ppx/ocamlformat#1383, @gpetiot)
+ Do not escape arguments of some Odoc tags (ocaml-ppx/ocamlformat#1391, 1408, @gpetiot, @Julow)
The characters `[]{}` must not be escaped in the arguments of `@raise`, `@author`, `@version` and others.
+ Fix missing open line between multi-line let-binding with poly-typexpr (ocaml-ppx/ocamlformat#1372, @jberdine)
+ Remove trailing space after expression when followed by an attribute and break before attributes attached to multi-line phrases (ocaml-ppx/ocamlformat#1382, @gpetiot)
+ Do not add a space to minimal comments `(* *)`, `(** *)` and `(*$ *)` (ocaml-ppx/ocamlformat#1407, @gpetiot)
+ Fix attributes position in labelled arguments type (ocaml-ppx/ocamlformat#1434, @gpetiot)
+ Add missing parens around type annotation in anonymous function (ocaml-ppx/ocamlformat#1433, @gpetiot)
+ Fix alignment of 'then' keyword in parenthesised expression (ocaml-ppx/ocamlformat#1421, @gpetiot)
#### New features
+ Support quoted extensions (added in ocaml 4.11) (ocaml-ppx/ocamlformat#1405, @gpetiot)
+ Recognise eliom file extensions (ocaml-ppx/ocamlformat#1430, @jrochel)
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.
The is_simple check for let bindings only considers the location of
the body exp. This location happens to usually be large enough. But
for one of a group of let bindings which has an explicit polymorphic
type constraint, the location of the body exp contains only the body,
and does not include the location of the pattern. This means that
cases such as:
get misformatted since
gis misidentified as being a one-liner, andthe open line between
fandggets removed.This patch fixes this by using the location of the entire let-binding
instead of the body expression.