@@ -700,7 +700,7 @@ and print_module_binding ~state ~is_rec module_binding cmt_tbl i =
700
700
match module_binding.pmb_expr with
701
701
| {pmod_desc = Pmod_constraint (mod_expr, mod_type)}
702
702
when not
703
- (ParsetreeViewer. has_await_attribute
703
+ (ParsetreeViewer. has_await_attribute2
704
704
module_binding.pmb_expr.pmod_attributes) ->
705
705
( print_mod_expr ~state mod_expr cmt_tbl,
706
706
Doc. concat [Doc. text " : " ; print_mod_type ~state mod_type cmt_tbl] )
@@ -3432,9 +3432,10 @@ and print_expression ~state (e : Parsetree.expression) cmt_tbl =
3432
3432
Doc. concat [Doc. text " \" " ; member_doc; Doc. text " \" " ]
3433
3433
in
3434
3434
Doc. group (Doc. concat [parent_doc; Doc. lbracket; member; Doc. rbracket])
3435
- in
3436
- let expr_with_await =
3437
- if ParsetreeViewer. has_await_attribute e.pexp_attributes then
3435
+ | Pexp_await e ->
3436
+ let printed_expression =
3437
+ print_expression_with_comments ~state e cmt_tbl
3438
+ in
3438
3439
let rhs =
3439
3440
match
3440
3441
Parens. lazy_or_assert_or_await_expr_rhs ~in_await: true
@@ -3453,7 +3454,6 @@ and print_expression ~state (e : Parsetree.expression) cmt_tbl =
3453
3454
| Nothing -> printed_expression
3454
3455
in
3455
3456
Doc. concat [Doc. text " await " ; rhs]
3456
- else printed_expression
3457
3457
in
3458
3458
let should_print_its_own_attributes =
3459
3459
match e.pexp_desc with
@@ -3467,11 +3467,11 @@ and print_expression ~state (e : Parsetree.expression) cmt_tbl =
3467
3467
| _ -> false
3468
3468
in
3469
3469
match e.pexp_attributes with
3470
- | [] -> expr_with_await
3470
+ | [] -> printed_expression
3471
3471
| attrs when not should_print_its_own_attributes ->
3472
3472
Doc. group
3473
- (Doc. concat [print_attributes ~state attrs cmt_tbl; expr_with_await ])
3474
- | _ -> expr_with_await
3473
+ (Doc. concat [print_attributes ~state attrs cmt_tbl; printed_expression ])
3474
+ | _ -> printed_expression
3475
3475
3476
3476
and print_pexp_fun ~state ~in_callback e cmt_tbl =
3477
3477
let async, parameters, return_expr = ParsetreeViewer. fun_expr e in
@@ -3761,7 +3761,10 @@ and print_binary_expression ~state (expr : Parsetree.expression) cmt_tbl =
3761
3761
| _ -> add_parens doc
3762
3762
in
3763
3763
let is_await =
3764
- ParsetreeViewer. has_await_attribute expr.pexp_attributes
3764
+ (match expr.pexp_desc with
3765
+ | Pexp_await _ -> true
3766
+ | _ -> false )
3767
+ || ParsetreeViewer. has_await_attribute expr
3765
3768
in
3766
3769
let doc =
3767
3770
if is_await then
@@ -5298,7 +5301,7 @@ and print_expression_block ~state ~braces expr cmt_tbl =
5298
5301
match mod_expr.pmod_desc with
5299
5302
| Pmod_constraint (mod_expr2, mod_type)
5300
5303
when not
5301
- (ParsetreeViewer. has_await_attribute mod_expr.pmod_attributes)
5304
+ (ParsetreeViewer. has_await_attribute2 mod_expr.pmod_attributes)
5302
5305
->
5303
5306
let name =
5304
5307
Doc. concat
@@ -5792,7 +5795,7 @@ and print_mod_expr ~state mod_expr cmt_tbl =
5792
5795
| Pmod_functor _ -> print_mod_functor ~state mod_expr cmt_tbl
5793
5796
in
5794
5797
let doc =
5795
- if ParsetreeViewer. has_await_attribute mod_expr.pmod_attributes then
5798
+ if ParsetreeViewer. has_await_attribute2 mod_expr.pmod_attributes then
5796
5799
match mod_expr.pmod_desc with
5797
5800
| Pmod_constraint _ ->
5798
5801
Doc. concat [Doc. text " await " ; Doc. lparen; doc; Doc. rparen]
0 commit comments