diff --git a/src/Ast.ml b/src/Ast.ml index 9b876c9ca4..d70354709c 100644 --- a/src/Ast.ml +++ b/src/Ast.ml @@ -761,6 +761,12 @@ end = struct , Ppat_construct ({txt= Lident "::"}, _) ) when tl == pat -> false + | ( Pat + { ppat_desc= + Ppat_construct + ({txt= Lident "::"}, Some {ppat_desc= Ppat_tuple [_; _]}) } + , (Ppat_construct _| Ppat_variant _) ) -> + false | ( Pat { ppat_desc= Ppat_construct @@ -931,6 +937,9 @@ end = struct | Pexp_record (flds, _) when List.exists flds ~f:(fun (_, e0) -> e0 == exp) -> exposed Non_apply exp (* Non_apply is perhaps pessimistic *) + | Pexp_record (_, Some ({pexp_desc= Pexp_apply ({pexp_desc= Pexp_ident {txt= Lident i}},_) } as e0)) + when e0 == exp && is_prefix_id i -> + false | Pexp_record (_, Some ({pexp_desc= Pexp_apply _} as e0)) when e0 == exp -> true diff --git a/src/Fmt_ast.ml b/src/Fmt_ast.ml index 13b34c84f1..51e492c388 100644 --- a/src/Fmt_ast.ml +++ b/src/Fmt_ast.ml @@ -1375,7 +1375,10 @@ and fmt_expression c ?(box= true) ?epi ?eol ?parens ?ext match e0.pexp_desc with | Pexp_array _ | Pexp_constraint _ | Pexp_record _ | Pexp_tuple _ -> (".", "") - | _ -> (".(", ")") + | _ -> + match sugar_list_exp e0 with + | Some _ -> (".", "") + | None -> (".(", ")") in hvbox 0 ( fits_breaks_if parens "" "("