Skip to content

Commit

Permalink
add fix (#55)
Browse files Browse the repository at this point in the history
Signed-off-by: alanechang <[email protected]>
  • Loading branch information
alanechang authored Jan 23, 2024
1 parent b978f42 commit ca80eda
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 7 deletions.
5 changes: 4 additions & 1 deletion lib/Ast.ml
Original file line number Diff line number Diff line change
Expand Up @@ -2616,11 +2616,14 @@ end = struct
, Some
( { pexp_desc=
( Pexp_ident _ | Pexp_constant _ | Pexp_record _
| Pexp_field _ )
| Pexp_constraint _ | Pexp_field _ )
; _ } as e0 ) )
when e0 == exp ->
false
| Pexp_record (_, Some e0) when e0 == exp -> true
| Pexp_override fields
when List.exists fields ~f:(fun (_, e0) -> e0 == exp) ->
exposed_right_exp Sequence exp
| Pexp_sequence (lhs, rhs) -> exp_in_sequence lhs rhs exp
| Pexp_apply (_, args)
when List.exists args ~f:(fun (_, e0) ->
Expand Down
11 changes: 6 additions & 5 deletions lib/Fmt_ast.ml
Original file line number Diff line number Diff line change
Expand Up @@ -2375,11 +2375,12 @@ and fmt_expression c ?(box = true) ?(pro = noop) ?eol ?parens
pro
$ hvbox
(Params.Indent.exp_constraint c.conf)
( wrap_fits_breaks ~space:false c.conf "(" ")"
( fmt_expression c (sub_exp ~ctx e)
$ fmt "@ : "
$ fmt_core_type c (sub_typ ~ctx t) )
$ fmt_atrs )
(Params.parens_if parens c.conf
( wrap_fits_breaks ~space:false c.conf "(" ")"
( fmt_expression c (sub_exp ~ctx e)
$ fmt "@ : "
$ fmt_core_type c (sub_typ ~ctx t) )
$ fmt_atrs ) )
| Pexp_construct ({txt= Lident (("()" | "[]") as txt); loc}, None) ->
let opn = char txt.[0] and cls = char txt.[1] in
pro
Expand Down
6 changes: 6 additions & 0 deletions test/passing/tests/attributes.ml
Original file line number Diff line number Diff line change
Expand Up @@ -444,3 +444,9 @@ let raise_length_mismatch name n1 n2 =
external unsafe_memset : t -> pos:int -> len:int -> char -> unit
= "bigstring_memset_stub"
[@@noalloc]

let _ = f ((1 : int) [@a])

let _ = f ((1 : int) [@a]) ((1 : int) [@a])

let _ = f (((1 : int) [@a] : (int[@b])) [@a]) ((1 : int) [@a])
2 changes: 1 addition & 1 deletion test/passing/tests/override.ml.ref
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ let _ = {<x = (x [@a] : (t[@b])) [@c]>}

let _ = {<x>}

let _ = {<x = (x [@a])>}
let _ = {<x = x [@a]>}

let _ = {<x>}

0 comments on commit ca80eda

Please sign in to comment.