diff --git a/CHANGELOG.md b/CHANGELOG.md index 94537a9e92..4355c3866d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/compiler/frontend/bs_builtin_ppx.ml b/compiler/frontend/bs_builtin_ppx.ml index 92f55fc2d8..ce521163a6 100644 --- a/compiler/frontend/bs_builtin_ppx.ml +++ b/compiler/frontend/bs_builtin_ppx.ml @@ -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 diff --git a/tests/tests/src/Import.mjs b/tests/tests/src/Import.mjs index 88bd6e1554..2209af645f 100644 --- a/tests/tests/src/Import.mjs +++ b/tests/tests/src/Import.mjs @@ -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; @@ -145,5 +158,7 @@ export { f5, f6, f7, + f8, + f9, } /* Not a pure module */ diff --git a/tests/tests/src/Import.res b/tests/tests/src/Import.res index 9cfd032fe8..47fa8807ea 100644 --- a/tests/tests/src/Import.res +++ b/tests/tests/src/Import.res @@ -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 => () + } +}