@@ -264,13 +264,29 @@ let expr_mapper ~async_context ~in_function_def (self : mapper)
264
264
let async_saved = ! async_context in
265
265
let result = expr_mapper ~async_context ~in_function_def self e in
266
266
async_context := async_saved;
267
- match Ast_attributes. has_await_payload e.pexp_attributes with
267
+ let is_module, has_await =
268
+ match e.pexp_desc with
269
+ | Pexp_letmodule (_, {pmod_desc = Pmod_ident _; pmod_attributes}, _)
270
+ | Pexp_letmodule
271
+ ( _,
272
+ {
273
+ pmod_desc =
274
+ Pmod_constraint
275
+ ({pmod_desc = Pmod_ident _}, {pmty_desc = Pmty_ident _});
276
+ pmod_attributes;
277
+ },
278
+ _ ) ->
279
+ (true , Ast_attributes. has_await_payload pmod_attributes)
280
+ | _ -> (false , Ast_attributes. has_await_payload e.pexp_attributes)
281
+ in
282
+ match has_await with
268
283
| None -> result
269
284
| Some _ ->
270
285
if ! async_context = false then
271
286
Location. raise_errorf ~loc: e.pexp_loc
272
287
" Await on expression not in an async context" ;
273
- Ast_await. create_await_expression result
288
+ if is_module = false then Ast_await. create_await_expression result
289
+ else result
274
290
275
291
let typ_mapper (self : mapper ) (typ : Parsetree.core_type ) =
276
292
Ast_core_type_class_type. typ_mapper self typ
@@ -604,6 +620,7 @@ let rec structure_mapper ~await_context (self : mapper) (stru : Ast_structure.t)
604
620
| Pexp_let (_ , vbs , expr ) -> aux expr @ spelunk_vbs acc vbs
605
621
| Pexp_ifthenelse (_ , then_expr , Some else_expr ) ->
606
622
aux then_expr @ aux else_expr
623
+ | Pexp_construct (_ , Some expr ) -> aux expr
607
624
| Pexp_fun (_ , _ , _ , expr ) | Pexp_newtype (_ , expr ) -> aux expr
608
625
| _ -> acc
609
626
in
0 commit comments