Skip to content

Commit 23e0460

Browse files
committed
fix using await module instead of async function
1 parent b9df8ac commit 23e0460

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

jscomp/frontend/bs_builtin_ppx.ml

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,13 +264,29 @@ let expr_mapper ~async_context ~in_function_def (self : mapper)
264264
let async_saved = !async_context in
265265
let result = expr_mapper ~async_context ~in_function_def self e in
266266
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
268283
| None -> result
269284
| Some _ ->
270285
if !async_context = false then
271286
Location.raise_errorf ~loc:e.pexp_loc
272287
"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
274290

275291
let typ_mapper (self : mapper) (typ : Parsetree.core_type) =
276292
Ast_core_type_class_type.typ_mapper self typ

0 commit comments

Comments
 (0)