From 4386164d76ea42fbec5eaa659792e27d60a46e19 Mon Sep 17 00:00:00 2001 From: mununki Date: Thu, 12 Oct 2023 02:06:38 +0900 Subject: [PATCH 1/4] fix using await module instead of async function --- jscomp/frontend/bs_builtin_ppx.ml | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/jscomp/frontend/bs_builtin_ppx.ml b/jscomp/frontend/bs_builtin_ppx.ml index a2a8417a41..3bcf907fca 100644 --- a/jscomp/frontend/bs_builtin_ppx.ml +++ b/jscomp/frontend/bs_builtin_ppx.ml @@ -264,13 +264,29 @@ let expr_mapper ~async_context ~in_function_def (self : mapper) let async_saved = !async_context in let result = expr_mapper ~async_context ~in_function_def self e in async_context := async_saved; - match Ast_attributes.has_await_payload e.pexp_attributes with + let is_module, has_await = + match e.pexp_desc with + | Pexp_letmodule (_, {pmod_desc = Pmod_ident _; pmod_attributes}, _) + | Pexp_letmodule + ( _, + { + pmod_desc = + Pmod_constraint + ({pmod_desc = Pmod_ident _}, {pmty_desc = Pmty_ident _}); + pmod_attributes; + }, + _ ) -> + (true, Ast_attributes.has_await_payload pmod_attributes) + | _ -> (false, Ast_attributes.has_await_payload e.pexp_attributes) + in + match has_await with | None -> result | Some _ -> if !async_context = false then Location.raise_errorf ~loc:e.pexp_loc "Await on expression not in an async context"; - Ast_await.create_await_expression result + if is_module = false then Ast_await.create_await_expression result + else result let typ_mapper (self : mapper) (typ : Parsetree.core_type) = Ast_core_type_class_type.typ_mapper self typ From 03501b20ea496237740795024b3fc3d019e48248 Mon Sep 17 00:00:00 2001 From: mununki Date: Thu, 12 Oct 2023 02:10:03 +0900 Subject: [PATCH 2/4] changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8402a05b2f..838c98bdcc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ - Fix issue with Dynamic import of module in nested expressions https://github.com/rescript-lang/rescript-compiler/pull/6431 - Fix issue where GenType was not supporting `@tag` on ordinary variatns https://github.com/rescript-lang/rescript-compiler/pull/6437 +- Fixed using dynamic import of module in block instead of async function https://github.com/rescript-lang/rescript-compiler/pull/6434 #### :nail_care: Polish From e4125ac00df9b849c5d588b417644d83cfb67ca7 Mon Sep 17 00:00:00 2001 From: mununki Date: Thu, 12 Oct 2023 02:10:57 +0900 Subject: [PATCH 3/4] changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 838c98bdcc..b5a0809c71 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,7 +16,7 @@ - Fix issue with Dynamic import of module in nested expressions https://github.com/rescript-lang/rescript-compiler/pull/6431 - Fix issue where GenType was not supporting `@tag` on ordinary variatns https://github.com/rescript-lang/rescript-compiler/pull/6437 -- Fixed using dynamic import of module in block instead of async function https://github.com/rescript-lang/rescript-compiler/pull/6434 +- Fix using dynamic import of module in block instead of async function https://github.com/rescript-lang/rescript-compiler/pull/6434 #### :nail_care: Polish From a0c1f45f0ee2aeb16aa032b6c792df17b584b21d Mon Sep 17 00:00:00 2001 From: mununki Date: Thu, 12 Oct 2023 02:32:37 +0900 Subject: [PATCH 4/4] fix error dynamic import of module in uncurried --- CHANGELOG.md | 3 ++- jscomp/frontend/bs_builtin_ppx.ml | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b5a0809c71..e6e760f6db 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,9 +14,10 @@ #### :bug: Bug Fix -- Fix issue with Dynamic import of module in nested expressions https://github.com/rescript-lang/rescript-compiler/pull/6431 +- Fix issue with dynamic import of module in nested expressions https://github.com/rescript-lang/rescript-compiler/pull/6431 - Fix issue where GenType was not supporting `@tag` on ordinary variatns https://github.com/rescript-lang/rescript-compiler/pull/6437 - Fix using dynamic import of module in block instead of async function https://github.com/rescript-lang/rescript-compiler/pull/6434 +- Fix issue with using dynamic import of module in uncurried mode https://github.com/rescript-lang/rescript-compiler/pull/6434 #### :nail_care: Polish diff --git a/jscomp/frontend/bs_builtin_ppx.ml b/jscomp/frontend/bs_builtin_ppx.ml index 3bcf907fca..96c8389313 100644 --- a/jscomp/frontend/bs_builtin_ppx.ml +++ b/jscomp/frontend/bs_builtin_ppx.ml @@ -620,6 +620,7 @@ let rec structure_mapper ~await_context (self : mapper) (stru : Ast_structure.t) | Pexp_let (_, vbs, expr) -> aux expr @ spelunk_vbs acc vbs | Pexp_ifthenelse (_, then_expr, Some else_expr) -> aux then_expr @ aux else_expr + | Pexp_construct (_, Some expr) -> aux expr | Pexp_fun (_, _, _, expr) | Pexp_newtype (_, expr) -> aux expr | _ -> acc in