From 938aa5eca92d66e5308e2cee25190f34b729dd9a Mon Sep 17 00:00:00 2001 From: Jules Aguillon Date: Fri, 25 Oct 2024 11:44:30 +0200 Subject: [PATCH 1/3] Fix parenthesing of let in class expressions --- lib/Ast.ml | 1 + test/passing/tests/class_expr.ml | 5 +++++ 2 files changed, 6 insertions(+) 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..58c5a9f151 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) + () From 3e670bba72f64be1fd8dba4186c826509795fe19 Mon Sep 17 00:00:00 2001 From: Jules Aguillon Date: Fri, 25 Oct 2024 11:46:15 +0200 Subject: [PATCH 2/3] Update CHANGES --- CHANGES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.md b/CHANGES.md index 33e53db8bb..7029437c40 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -58,6 +58,7 @@ profile. This started with version 0.26.0. The attribute is moved from `begin .. end [@attr]` to `begin [@attr] .. end`. - Fix missing parentheses around `let .. in [@attr]` (#2564, @Julow) - Display `a##b` instead of `a ## b` and similarly for operators that start with # (#2580, @v-gb) +- 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) From 371c27425a5e72d6568da5666a062ac94b69199b Mon Sep 17 00:00:00 2001 From: Jules Aguillon Date: Mon, 28 Oct 2024 10:50:25 +0100 Subject: [PATCH 3/3] Promote tests --- test/passing/tests/class_expr.ml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/passing/tests/class_expr.ml b/test/passing/tests/class_expr.ml index 58c5a9f151..89f61866d5 100644 --- a/test/passing/tests/class_expr.ml +++ b/test/passing/tests/class_expr.ml @@ -18,5 +18,5 @@ class c = class c = (let () = print_endline "Class init" in - with_param) + with_param ) ()