Skip to content
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
- Preserve `@as(...)` decorator on record fields when creating interface. https://github.com/rescript-lang/rescript/pull/7779
- Fix parse error with nested record types and attributes on the field name that has the nested record type. https://github.com/rescript-lang/rescript/pull/7781
- Fix ppx resolution with package inside monorepo. https://github.com/rescript-lang/rescript/pull/7776
- Fix 'Unbound module type' errors that occurred when trying to async import modules. https://github.com/rescript-lang/rescript/pull/7783

#### :memo: Documentation

Expand Down
8 changes: 8 additions & 0 deletions compiler/frontend/bs_builtin_ppx.ml
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,14 @@ let rec structure_mapper ~await_context (self : mapper) (stru : Ast_structure.t)
aux then_expr @ aux else_expr
| Pexp_construct (_, Some expr) -> aux expr
| Pexp_fun {rhs = expr} | Pexp_newtype (_, expr) -> aux expr
| Pexp_constraint (expr, _) -> aux expr
| Pexp_match (expr, cases) ->
let case_results =
List.fold_left
(fun acc (case : Parsetree.case) -> aux case.pc_rhs @ acc)
[] cases
in
aux expr @ case_results
| _ -> acc
in
aux pvb_expr @ spelunk_vbs acc tl
Expand Down
15 changes: 15 additions & 0 deletions tests/tests/src/Import.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,19 @@ async function f7() {
return 1;
}

async function f8() {
await import("rescript/lib/es6/Belt_MutableQueue.js");
return 1;
}

async function f9(value) {
if (value !== undefined) {
await import("rescript/lib/es6/Belt_HashMapInt.js");
return;
}

}

let each = M1.forEach;

let M2;
Expand All @@ -145,5 +158,7 @@ export {
f5,
f6,
f7,
f8,
f9,
}
/* Not a pure module */
14 changes: 14 additions & 0 deletions tests/tests/src/Import.res
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,17 @@ let f7 = async () => {
0
}
}

let f8 = async (): int => {
module MQ = await Belt.MutableQueue
1
}

let f9 = async value => {
switch value {
| Some(_) =>
module HashMapInt = await Belt.HashMap.Int
()
| None => ()
}
}
Loading