@@ -217,29 +217,27 @@ let expr_mapper ~async_context ~in_function_def (self : mapper)
217
217
let async_saved = ! async_context in
218
218
let result = expr_mapper ~async_context ~in_function_def self e in
219
219
async_context := async_saved;
220
- let is_module, has_await =
221
- match e.pexp_desc with
222
- | Pexp_letmodule (_, {pmod_desc = Pmod_ident _; pmod_attributes}, _)
223
- | Pexp_letmodule
224
- ( _,
225
- {
226
- pmod_desc =
227
- Pmod_constraint
228
- ({pmod_desc = Pmod_ident _}, {pmty_desc = Pmty_ident _});
229
- pmod_attributes;
230
- },
231
- _ ) ->
232
- (true , Ast_attributes. has_await_payload pmod_attributes)
233
- | _ -> (false , Ast_attributes. has_await_payload e.pexp_attributes)
234
- in
235
- match has_await with
236
- | None -> result
237
- | Some _ ->
220
+ let check_await () =
238
221
if ! async_context = false then
239
222
Location. raise_errorf ~loc: e.pexp_loc
240
- " Await on expression not in an async context" ;
241
- if is_module = false then Ast_await. create_await_expression result
242
- else result
223
+ " Await on expression not in an async context"
224
+ in
225
+ match e.pexp_desc with
226
+ | Pexp_letmodule (_, {pmod_desc = Pmod_ident _; pmod_attributes}, _)
227
+ | Pexp_letmodule
228
+ ( _,
229
+ {
230
+ pmod_desc =
231
+ Pmod_constraint ({pmod_desc = Pmod_ident _; pmod_attributes}, _);
232
+ },
233
+ _ )
234
+ when Ast_attributes. has_await_payload pmod_attributes ->
235
+ check_await () ;
236
+ result
237
+ | _ when Ast_attributes. has_await_payload e.pexp_attributes ->
238
+ check_await () ;
239
+ Ast_await. create_await_expression result
240
+ | _ -> result
243
241
244
242
let typ_mapper (self : mapper ) (typ : Parsetree.core_type ) =
245
243
Ast_core_type_class_type. typ_mapper self typ
0 commit comments