Skip to content

Commit 330b256

Browse files
authored
Fix allowing using dyanmic import of module instead of async function (#6434)
* fix using await module instead of async function * changelog * changelog * fix error dynamic import of module in uncurried
1 parent dc7eb63 commit 330b256

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@
1414

1515
#### :bug: Bug Fix
1616

17-
- Fix issue with Dynamic import of module in nested expressions https://github.com/rescript-lang/rescript-compiler/pull/6431
17+
- Fix issue with dynamic import of module in nested expressions https://github.com/rescript-lang/rescript-compiler/pull/6431
1818
- Fix issue where GenType was not supporting `@tag` on ordinary variatns https://github.com/rescript-lang/rescript-compiler/pull/6437
19+
- Fix using dynamic import of module in block instead of async function https://github.com/rescript-lang/rescript-compiler/pull/6434
20+
- Fix issue with using dynamic import of module in uncurried mode https://github.com/rescript-lang/rescript-compiler/pull/6434
1921

2022
#### :nail_care: Polish
2123

jscomp/frontend/bs_builtin_ppx.ml

Lines changed: 19 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
@@ -604,6 +620,7 @@ let rec structure_mapper ~await_context (self : mapper) (stru : Ast_structure.t)
604620
| Pexp_let (_, vbs, expr) -> aux expr @ spelunk_vbs acc vbs
605621
| Pexp_ifthenelse (_, then_expr, Some else_expr) ->
606622
aux then_expr @ aux else_expr
623+
| Pexp_construct (_, Some expr) -> aux expr
607624
| Pexp_fun (_, _, _, expr) | Pexp_newtype (_, expr) -> aux expr
608625
| _ -> acc
609626
in

0 commit comments

Comments
 (0)