diff --git a/CHANGES.md b/CHANGES.md index b07e252037..e5207a8e79 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -60,6 +60,7 @@ profile. This started with version 0.26.0. - Display `a##b` instead of `a ## b` and similarly for operators that start with # (#2580, @v-gb) - \* Fix arrow type indentation with `break-separators=before` (#2598, @Julow) - Fix formatting of short `fun` expressions with the janestreet profile (#2593, @Julow) +- Fix missing parentheses around a let in class expressions (#2599, @Julow) ### Changes - The location of attributes for structure items is now tracked and preserved. (#2247, @EmileTrotignon) diff --git a/lib/Ast.ml b/lib/Ast.ml index 008202ff71..55e326babe 100644 --- a/lib/Ast.ml +++ b/lib/Ast.ml @@ -1777,6 +1777,7 @@ end = struct match c.pcl_desc with | Pcl_apply _ -> Some Apply | Pcl_structure _ -> Some Apply + | Pcl_let _ -> Some Low | _ -> None ) | Top | Pat _ | Mty _ | Mod _ | Sig _ | Str _ | Tli _ | Clf _ | Ctf _ |Rep | Mb _ | Md _ | Cd _ | Ctd _ -> diff --git a/test/passing/tests/class_expr.ml b/test/passing/tests/class_expr.ml index f667e84954..89f61866d5 100644 --- a/test/passing/tests/class_expr.ml +++ b/test/passing/tests/class_expr.ml @@ -15,3 +15,8 @@ class c = let pci_params = self#list in () end + +class c = + (let () = print_endline "Class init" in + with_param ) + ()