Skip to content

Conversation

@Julow
Copy link
Collaborator

@Julow Julow commented Jul 25, 2023

Changes that are backported:

  • New Pmod_apply_unit module type constructor. We had a similar concept in parse-extended, so this is just a rename.

  • New value_constraint field in value bindings.
    This makes the parser less permissive about bugs in the formatting of
    type annotation on let-bindings.

  • Some changes in Location and Ast_mapper are not necessary but are
    backported to reduce the diff.

  • String assignment operator has been removed upstream but remains
    supported by commenting out the change.

  • Dead code in parser-extended have been removed in the past. I reverted that
    and commented-out the code instead. This makes the code more similar with
    parser-standard and helps recognize new code.

  • Ast rules have changed as some constructions are no longer special.

Julow added 10 commits July 24, 2023 12:46
- New `Pmod_apply_unit` module type constructor.

- New `value_constraint` field in value bindings.
  This makes the parser less permissive about bugs in the formatting of
  type annotation on let-bindings.

- Some changes in `Location` and `Ast_mapper` are not necessary but are
  backported to reduce the diff.

- String assignment operator has been removed upstream but remains
  supported by commenting out the change.
The extended AST already had a similar constructor.
This is just a rename.
Add commented-out unused code instead of removing it. This helps
backporting new changes by making the code looks more similar to
the upstream parser and helps to recognize added code.
We already had a similar AST node but the `value_constraint` field is
new and helps removing complex code in Sugar.

The `pvb_is_pun` field is kept from the previous extended representation.
instead of the extended parser (the default).
let foo : type a' b'. a' -> b' = fun a -> assert false
let foo : type t'. t' = fun (type t') : t' -> assert false
let foo : type t. t = assert false
let foo : 't. 't = fun (type t) : t -> assert false
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This rewrite is no longer done.

let x : int = x in
let (_ : int) = x in
let (_ : int) = x in
let _ : int = x in
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Parentheses around let-binding patterns follow the original source. These are two different AST now.
Shouldn't change existing code.

Comment on lines +3 to +5
let t2
: 'a 'b.
'a t________________________________ -> 'b t_______________________________________
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not consider this a regression as it's the formatting used in slightly different cases.

@Julow
Copy link
Collaborator Author

Julow commented Jul 26, 2023

test_branch shows some regressions but I'm tempted to accept them as improvements.

Some patterns are no longer recognized as Ppat_constraint but rather a let-binding with annotation. Showing the inconsistency between the two code paths.

index f2e9236473..27701537f5 100644
--- a/infer/src/pulse/PulseCallOperations.ml
+++ b/infer/src/pulse/PulseCallOperations.ml
@@ -233,8 +233,8 @@ let apply_callee tenv ({ PathContext.timestamp } as path) ~caller_proc_desc
         let caller_return_var : Pvar.t =
           Procdesc.get_ret_var caller_proc_desc
         in
-        let (astate, caller_return_val_hist)
-              : AbductiveDomain.t * (AbstractValue.t * ValueHistory.t) =
+        let (astate, caller_return_val_hist) :
+            AbductiveDomain.t * (AbstractValue.t * ValueHistory.t) =
           PulseOperations.eval_var path call_loc caller_return_var astate
         in
         let+ (astate : AbductiveDomain.t) =

Some patterns were parenthesed because the expression was a Pexp_constraint. This bug is gone:

index 2a34ec8b1..faaf464be 100644
--- a/testsuite/tests/typing-poly/poly.ml
+++ b/testsuite/tests/typing-poly/poly.ml
@@ -1888,11 +1888,11 @@ module Polux :
 
 (* PR#5560 *)
 
-let (a, b) = (raise Exit : int * int)
+let a, b = (raise Exit : int * int)
 
 type t = { foo : int }
 
-let ({ foo }) = (raise Exit : t)
+let { foo } = (raise Exit : t)
 
 type s = A of int

This might also be an inconsistency between two code paths, though I can't pin it down yet.

index 395387a93..8b7b830aa 100644
--- a/src/memo/memo.ml
+++ b/src/memo/memo.ml
@@ -1051,9 +1051,9 @@ module Exec : sig
   val exec_dep_node : ('i, 'o) Dep_node.t -> 'o Fiber.t
 end = struct
   let rec restore_from_cache :
-            'o.
-            cached_value:'o Cached_value.t ->
-            'o Cached_value.t Cache_lookup.Result.t Fiber.t =
+        'o.
+        cached_value:'o Cached_value.t ->
+        'o Cached_value.t Cache_lookup.Result.t Fiber.t =
    fun ~cached_value ->
     match cached_value.value with
     | Cancelled _dependency_cycle ->

CHANGES.md Outdated

### New features

- Compatible with OCaml 5.1.0-beta1 (#2412, @Julow)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The regressions are small in size and affect rare code. I would not mark this as breaking.

For consistency with the new 'value_binding'.
@Julow Julow merged commit f623b63 into ocaml-ppx:main Sep 5, 2023
Julow added a commit to Julow/opam-repository that referenced this pull request Sep 15, 2023
….26.1)

CHANGES:

### Changed

- Compatible with OCaml 5.1.0 (ocaml-ppx/ocamlformat#2412, @Julow)
  The syntax of let-bindings changed sligthly in this version.
- Improved ocp-indent compatibility (ocaml-ppx/ocamlformat#2428, @Julow)
- \* Removed extra break in constructor declaration with comment (ocaml-ppx/ocamlformat#2429, @Julow)
- \* De-indent the `object` keyword in class types (ocaml-ppx/ocamlformat#2425, @Julow)
- \* Consistent formatting of arrows in class types (ocaml-ppx/ocamlformat#2422, @Julow)

### Fixed

- Fix dropped attributes on a begin-end in a match case (ocaml-ppx/ocamlformat#2421, @Julow)
- Fix dropped attributes on begin-end in an if-then-else branch (ocaml-ppx/ocamlformat#2436, @gpetiot)
- Fix non-stabilizing comments before a functor type argument (ocaml-ppx/ocamlformat#2420, @Julow)
- Fix crash caused by module types with nested `with module` (ocaml-ppx/ocamlformat#2419, @Julow)
- Fix ';;' formatting between doc-comments and toplevel directives (ocaml-ppx/ocamlformat#2432, @gpetiot)
nberth pushed a commit to nberth/opam-repository that referenced this pull request Jun 18, 2024
….26.1)

CHANGES:

### Changed

- Compatible with OCaml 5.1.0 (ocaml-ppx/ocamlformat#2412, @Julow)
  The syntax of let-bindings changed sligthly in this version.
- Improved ocp-indent compatibility (ocaml-ppx/ocamlformat#2428, @Julow)
- \* Removed extra break in constructor declaration with comment (ocaml-ppx/ocamlformat#2429, @Julow)
- \* De-indent the `object` keyword in class types (ocaml-ppx/ocamlformat#2425, @Julow)
- \* Consistent formatting of arrows in class types (ocaml-ppx/ocamlformat#2422, @Julow)

### Fixed

- Fix dropped attributes on a begin-end in a match case (ocaml-ppx/ocamlformat#2421, @Julow)
- Fix dropped attributes on begin-end in an if-then-else branch (ocaml-ppx/ocamlformat#2436, @gpetiot)
- Fix non-stabilizing comments before a functor type argument (ocaml-ppx/ocamlformat#2420, @Julow)
- Fix crash caused by module types with nested `with module` (ocaml-ppx/ocamlformat#2419, @Julow)
- Fix ';;' formatting between doc-comments and toplevel directives (ocaml-ppx/ocamlformat#2432, @gpetiot)
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.

2 participants