这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/Ast.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion src/Fmt_ast.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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 "" "("
Expand Down