Skip to content

Commit 23a4197

Browse files
cknittclaude
andauthored
Represent await on module expressions with a Pmod_await node (#8738)
* Represent await on module expressions with a Pmod_await node `await M` on a module expression was stored as a `res.await` attribute on M, while expressions already have `Pexp_await`. Add `Pmod_await` and have the parser produce it, so `res.await` only remains in the v0 PPX wire representation: `Ast_mapper_to0` writes it like for `Pexp_await` (the await node's attributes, the marker, then the inner module's) and `Ast_mapper_from0` splits them again. The frontend recognizes awaited module paths structurally (`Ast_await.awaited_module_path`) for the dynamic import rewrite and the async context check. Any other `await` on a module still has no effect: the type checker types `Pmod_await M` as `M`. Errors on an awaited module now point at the whole `await M`. The printer no longer special-cases a `res.await` attribute: `await` is printed by its own node, which also lets `await @w (await X)` and `@w (await X)` round-trip. Formatting of existing code is unchanged. Bump the current AST magic numbers for the new constructor. Signed-off-by: Christoph Knittel <christoph@knittel.cc> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Add CHANGELOG link for #8738 Signed-off-by: Christoph Knittel <christoph@knittel.cc> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Detect doc comments on awaited functor arguments An await node's own attributes print before it, so a doc comment on it starts the printed argument: F((/** doc */ (await X))) printed as F(/** doc */ (await X)), which doesn't parse. Only a functor's attributes print elsewhere (on its first parameter). Signed-off-by: Christoph Knittel <christoph@knittel.cc> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Keep await locations across v0 and attributes in dynamic imports The v0 bridge folds an await node and its operand into one node, marked with `res.await`. The marker was written without a location, so after a round trip through an external PPX the await node took its operand's location and lost the span of the `await` keyword. Store the await node's location on the marker, like `res.braces` does, and restore it, falling back to the node's location for markers without one. This also applies to `Pexp_await`, which had the same problem. The dynamic import rewrite replaced an await node with its operand and dropped the await node's attributes, e.g. a `@warning` in `(@warning("-3") (await List): ListT)` as a PPX may produce it. Keep them on the imported module, as when await was an attribute. Signed-off-by: Christoph Knittel <christoph@knittel.cc> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Recognize nested awaits as dynamic imports `module M = await (await List)` used to be a dynamic import: both awaits became `res.await` attributes on the same node. With `Pmod_await` it is two nested nodes, and the dynamic import forms only looked through one, so it silently became a static module reference and skipped the async context check. `Ast_await.awaited_module_path` now looks through any number of awaits around the module path and around the constraint, and the toplevel and local module type pre-scans use it too. `create_await_module_expression` removes nested awaits as well. Compiling 19 module await forms in 5 contexts gives the same JavaScript and errors as master. Signed-off-by: Christoph Knittel <christoph@knittel.cc> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Simplify the module dynamic import rewrite `awaited_module_path` and `create_await_module_expression` each removed the awaits around a dynamic import, the second time keeping their attributes. `awaited_module_path` now returns the module to import with its awaits removed and their attributes kept, and `create_await_module_expression` just packs it. The toplevel and local module cases each declared `module type __List__ = module type of List` once per module with the same code; it is now `local_module_type_decl`. Both callers bind its result before mapping the rest, since a later import of the same module must find it already declared. Signed-off-by: Christoph Knittel <christoph@knittel.cc> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Respect @warning on the module in module type of `type_module_type_of` looked a module path up without the warning scope of the module's attributes, unlike `type_module`, so `module type of @warning("-3") DeprecatedModule` still reported warning 3. That includes the `module type __M__ = module type of M` a dynamic import declares, so `module M = @warning("-3") (await DeprecatedModule)` reported it too (also before `Pmod_await`). Look the module up in that scope. Signed-off-by: Christoph Knittel <christoph@knittel.cc> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Remove no-op module awaits before type checking Outside the dynamic import forms, `await` on a module has no effect; as a `res.await` attribute it was invisible to the type checker. As a `Pmod_await` node it hid the module's shape where the type checker treats shapes specially: `module type of await M` was strengthened (abstract types became `M.t`) instead of taking the unstrengthened module path, and `F(await {})` was rejected for a generative functor. Like `Pexp_await`, which never reaches the type checker, the builtin ppx now removes the remaining awaits after the dynamic import rewrite, keeping their attributes on the module they wrap. The type checker's `Pmod_await` case only remains for trees that bypass it. Type checking every input of the module expression round-trip harness (7950 cases) gives the same exit codes, JavaScript and errors as master. Signed-off-by: Christoph Knittel <christoph@knittel.cc> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Share the module await removal Signed-off-by: Christoph Knittel <christoph@knittel.cc> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Keep the legacy v0 attribute order of module await PPXs saw await on a module as the res.await attribute, after the module's own attributes and before those written after await or around the await: [await @b (@A M)] was [@A; res.await; @b]. The attributes after await now belong to the Pmod_await node, as those of [@b (await M)] already did, and the v0 bridge emits them in that order. The printer prints an await's attributes after await and parenthesizes an attributed operand. Signed-off-by: Christoph Knittel <christoph@knittel.cc> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Name the module await helper Mod.await The trailing underscore in Ast_helper is for OCaml keywords, as in Mod.functor_ and Mod.constraint_; await isn't one, and the expression helper is Exp.await. Signed-off-by: Christoph Knittel <christoph@knittel.cc> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Signed-off-by: Christoph Knittel <christoph@knittel.cc> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
1 parent ac96983 commit 23a4197

35 files changed

Lines changed: 629 additions & 225 deletions

‎CHANGELOG.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
#### :bug: Bug fix
2525

26+
- Respect `@warning` attributes on the module in `module type of`, e.g. `module type of @warning("-3") DeprecatedModule`, which still reported the warning. https://github.com/rescript-lang/rescript/pull/8738
2627
- Fix the formatter dropping or moving attributes and `await` on module expressions, such as `module M = @attr F(X)`, and printing invalid code for module constraints and functors in some positions, such as `module M: T = (X: S)`. https://github.com/rescript-lang/rescript/pull/8735
2728
- Make rewatch compile independent modules after an unrelated failure and recompile blocked dependents when a changed interface survives a failed implementation, including across full watcher rebuilds. https://github.com/rescript-lang/rescript/pull/8667
2829
- Fix `RescriptTools.binaryPath` failing with `ERR_PACKAGE_IMPORT_NOT_DEFINED` when used from a user project. https://github.com/rescript-lang/rescript/pull/8694
@@ -44,6 +45,7 @@
4445

4546
#### :house: Internal
4647

48+
- Represent `await` on module expressions with a dedicated `Pmod_await` parsetree node instead of a `res.await` attribute, which remains only in the PPX wire representation. https://github.com/rescript-lang/rescript/pull/8738
4749
- Remove dead compiler code: warning 24, the `J.String_index` JS IR node, the `Pisint` and `Parraysets` Lambda primitives with their unused `%` primitive names (`%obj_is_int`, `%obj_dup`, `%obj_field`, `%array_safe_set`, `%null_to_opt`, `%nullable_to_opt`), the no-op `-pp` bsc flag and unread `Clflags` fields (`-unsafe` stays accepted as an explicit no-op), and the unused `unit` slot of `Pexp_coerce`. https://github.com/rescript-lang/rescript/pull/8731
4850
- Represent inline record definitions with an explicit parsetree origin while retaining the existing PPX wire representation. https://github.com/rescript-lang/rescript/pull/8686
4951
- Make expression attributes immutable in the current parsetree, now that editor refactors construct new expression nodes. https://github.com/rescript-lang/rescript/pull/8685

‎compiler/ext/config.ml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ let cmi_magic_number = "Caml1999I035"
22

33
(* Magic numbers for marshaled values of the *current* parsetree, whose layout
44
changes across compiler versions. *)
5-
and ast_impl_magic_number = "ResImpl01311"
5+
and ast_impl_magic_number = "ResImpl01312"
66

7-
and ast_intf_magic_number = "ResIntf01311"
7+
and ast_intf_magic_number = "ResIntf01312"
88

99
(* Magic numbers of the frozen Parsetree0 (OCaml 4.06) layout used on the
1010
external-PPX wire. They must never be written in front of a

‎compiler/frontend/ast_attributes.ml‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,6 @@ let is_inline : attr -> bool = fun ({txt}, _) -> txt = "inline"
8585

8686
let has_inline_payload (attrs : t) = Ext_list.find_first attrs is_inline
8787

88-
let has_await_payload (attrs : t) = Ext_list.exists attrs Ast_await.is_await
89-
9088
type derive_attr = {bs_deriving: Ast_payload.action list option} [@@unboxed]
9189

9290
let process_derive_type (attrs : t) : derive_attr * t =

‎compiler/frontend/ast_attributes.mli‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ val process_attributes_rev : t -> attr_kind * t
3131

3232
val has_inline_payload : t -> attr option
3333

34-
val has_await_payload : t -> bool
35-
3634
type derive_attr = {bs_deriving: Ast_payload.action list option} [@@unboxed]
3735

3836
val arg_encoding : t -> [`Nothing | `String | `Int | `Ignore | `Unwrap]

‎compiler/frontend/bs_builtin_ppx.ml‎

Lines changed: 92 additions & 115 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,20 @@ let local_module_type_name txt =
113113
^ (Longident.flatten txt |> List.fold_left (fun ll l -> ll ^ "_" ^ l) "")
114114
^ "__"
115115

116+
(* [module type __List__ = module type of List], the module type a dynamic
117+
import of [List] unpacks to, declared once per module *)
118+
let local_module_type_decl ~await_context
119+
({txt; loc} : Longident.t Asttypes.loc) (me : Parsetree.module_expr) =
120+
let name = local_module_type_name txt in
121+
if Hashtbl.mem !await_context name then []
122+
else (
123+
Hashtbl.add !await_context name name;
124+
[
125+
Ast_helper.(
126+
Str.modtype ~loc
127+
(Mtd.mk ~loc {txt = name; loc} ~typ:(Mty.typeof_ ~loc me)));
128+
])
129+
116130
let expr_mapper ~async_context ~in_function_def (self : mapper)
117131
(e : Parsetree.expression) =
118132
let old_in_function_def = !in_function_def in
@@ -396,44 +410,30 @@ let expr_mapper ~async_context ~in_function_def (self : mapper)
396410
the attribute to the whole expression, in general, when shuffuling the ast
397411
it is very hard to place attributes correctly
398412
*)
399-
(* module M = await List *)
400-
| Pexp_letmodule
401-
(lid, ({pmod_desc = Pmod_ident {txt}; pmod_attributes} as me), expr)
402-
when Res_parsetree_viewer.has_await_attribute pmod_attributes ->
403-
let safe_module_type_lid : Ast_helper.lid =
404-
{txt = Lident (local_module_type_name txt); loc = me.pmod_loc}
413+
(* module M = await List, module M = await (List: ListType) *)
414+
| Pexp_letmodule (lid, me, expr) -> (
415+
let dynamic_import module_type_lid imported =
416+
{
417+
e with
418+
pexp_desc =
419+
Pexp_letmodule
420+
( lid,
421+
Ast_await.create_await_module_expression ~module_type_lid me
422+
imported,
423+
self.expr self expr );
424+
}
405425
in
406-
{
407-
e with
408-
pexp_desc =
409-
Pexp_letmodule
410-
( lid,
411-
Ast_await.create_await_module_expression
412-
~module_type_lid:safe_module_type_lid me,
413-
self.expr self expr );
414-
}
415-
(* module M = await (List: ListType) *)
416-
| Pexp_letmodule
417-
( lid,
418-
({
419-
pmod_desc =
420-
Pmod_constraint
421-
( {pmod_desc = Pmod_ident _; pmod_attributes = attrs1},
422-
{pmty_desc = Pmty_ident mtyp_lid} );
423-
pmod_attributes = attrs2;
424-
} as me),
425-
expr )
426-
when Res_parsetree_viewer.has_await_attribute attrs1
427-
|| Res_parsetree_viewer.has_await_attribute attrs2 ->
428-
{
429-
e with
430-
pexp_desc =
431-
Pexp_letmodule
432-
( lid,
433-
Ast_await.create_await_module_expression ~module_type_lid:mtyp_lid
434-
me,
435-
self.expr self expr );
436-
}
426+
match Ast_await.awaited_module_path me with
427+
| Some (module_lid, imported, None) ->
428+
dynamic_import
429+
{
430+
txt = Lident (local_module_type_name module_lid.txt);
431+
loc = module_lid.loc;
432+
}
433+
imported
434+
| Some (_, imported, Some {pmty_desc = Pmty_ident mtyp_lid}) ->
435+
dynamic_import mtyp_lid imported
436+
| Some (_, _, Some _) | None -> default_expr_mapper self e)
437437
| _ -> default_expr_mapper self e
438438

439439
let expr_mapper ~async_context ~in_function_def (self : mapper)
@@ -447,21 +447,8 @@ let expr_mapper ~async_context ~in_function_def (self : mapper)
447447
"Await on expression not in an async context"
448448
in
449449
match e.pexp_desc with
450-
| Pexp_letmodule (_, {pmod_desc = Pmod_ident _; pmod_attributes}, _)
451-
when Ast_attributes.has_await_payload pmod_attributes ->
452-
check_await ();
453-
result
454-
| Pexp_letmodule
455-
( _,
456-
{
457-
pmod_desc =
458-
Pmod_constraint
459-
({pmod_desc = Pmod_ident _; pmod_attributes = attrs1}, _);
460-
pmod_attributes = attrs2;
461-
},
462-
_ )
463-
when Ast_attributes.has_await_payload attrs1
464-
|| Ast_attributes.has_await_payload attrs2 ->
450+
| Pexp_letmodule (_, me, _)
451+
when Option.is_some (Ast_await.awaited_module_path me) ->
465452
check_await ();
466453
result
467454
| _ -> (
@@ -769,48 +756,39 @@ let rec structure_mapper ~await_context (self : mapper) (stru : Ast_structure.t)
769756
| _ -> expand_reverse acc (structure_mapper ~await_context self rest)
770757
in
771758
aux [] stru
772-
(* Dynamic import of module transformation: module M = @res.await List *)
773-
| Pstr_module
774-
({pmb_expr = {pmod_desc = Pmod_ident {txt; loc}; pmod_attributes} as me}
775-
as mb)
776-
when Res_parsetree_viewer.has_await_attribute pmod_attributes ->
777-
let item = self.structure_item self item in
778-
let safe_module_type_name = local_module_type_name txt in
779-
let has_local_module_name =
780-
Hashtbl.find_opt !await_context safe_module_type_name
781-
in
782-
(* module __List__ = module type of List *)
783-
let module_type_decl =
784-
match has_local_module_name with
785-
| Some _ -> []
786-
| None ->
787-
Hashtbl.add !await_context safe_module_type_name safe_module_type_name;
788-
[
789-
Ast_helper.(
790-
Str.modtype ~loc
791-
(Mtd.mk ~loc
792-
{txt = safe_module_type_name; loc}
793-
~typ:(Mty.typeof_ ~loc me)));
794-
]
795-
in
796-
let safe_module_type_lid : Ast_helper.lid =
797-
{txt = Lident safe_module_type_name; loc = mb.pmb_expr.pmod_loc}
798-
in
799-
module_type_decl
800-
@
801-
(* module M = @res.await List *)
802-
{
803-
item with
804-
pstr_desc =
805-
Pstr_module
806-
{
807-
mb with
808-
pmb_expr =
809-
Ast_await.create_await_module_expression
810-
~module_type_lid:safe_module_type_lid mb.pmb_expr;
811-
};
812-
}
813-
:: structure_mapper ~await_context self rest
759+
(* Dynamic import of module transformation: module M = await List *)
760+
| Pstr_module mb -> (
761+
match Ast_await.awaited_module_path mb.pmb_expr with
762+
| Some (module_lid, imported, None) ->
763+
let item = self.structure_item self item in
764+
let safe_module_type_lid : Ast_helper.lid =
765+
{
766+
txt = Lident (local_module_type_name module_lid.txt);
767+
loc = mb.pmb_expr.pmod_loc;
768+
}
769+
in
770+
(* Before mapping the rest, which may import the same module *)
771+
let module_type_decl =
772+
local_module_type_decl ~await_context module_lid imported
773+
in
774+
module_type_decl
775+
@
776+
(* module M = await List *)
777+
{
778+
item with
779+
pstr_desc =
780+
Pstr_module
781+
{
782+
mb with
783+
pmb_expr =
784+
Ast_await.create_await_module_expression
785+
~module_type_lid:safe_module_type_lid mb.pmb_expr imported;
786+
};
787+
}
788+
:: structure_mapper ~await_context self rest
789+
| _ ->
790+
self.structure_item self item
791+
:: structure_mapper ~await_context self rest)
814792
| Pstr_value (_, vbs) ->
815793
let item = self.structure_item self item in
816794
(* [ module __List__ = module type of List ] *)
@@ -820,27 +798,15 @@ let rec structure_mapper ~await_context (self : mapper) (stru : Ast_structure.t)
820798
| ({pvb_expr} : Parsetree.value_binding) :: tl ->
821799
let rec aux (expr : Parsetree.expression) =
822800
match expr.pexp_desc with
823-
| Pexp_letmodule
824-
( _,
825-
({pmod_desc = Pmod_ident {txt; loc}; pmod_attributes} as me),
826-
expr )
827-
when Res_parsetree_viewer.has_await_attribute pmod_attributes -> (
828-
let safe_module_type_name = local_module_type_name txt in
829-
let has_local_module_name =
830-
Hashtbl.find_opt !await_context safe_module_type_name
831-
in
832-
833-
match has_local_module_name with
834-
| Some _ -> aux expr
835-
| None ->
836-
Hashtbl.add !await_context safe_module_type_name
837-
safe_module_type_name;
838-
Ast_helper.(
839-
Str.modtype ~loc
840-
(Mtd.mk ~loc
841-
{txt = safe_module_type_name; loc}
842-
~typ:(Mty.typeof_ ~loc me)))
843-
:: aux expr)
801+
| Pexp_letmodule (_, me, expr) -> (
802+
match Ast_await.awaited_module_path me with
803+
| Some (module_lid, imported, None) ->
804+
(* Before [aux expr], which may import the same module *)
805+
let module_type_decl =
806+
local_module_type_decl ~await_context module_lid imported
807+
in
808+
module_type_decl @ aux expr
809+
| _ -> acc)
844810
| Pexp_let (_, vbs, expr) -> aux expr @ spelunk_vbs acc vbs
845811
| Pexp_braces {expr} -> aux expr
846812
| Pexp_ifthenelse (_, then_expr, Some else_expr) ->
@@ -876,9 +842,20 @@ let structure_mapper ~await_context (self : mapper) (stru : Ast_structure.t) =
876842
await_context := await_saved;
877843
result
878844

845+
(* Outside the dynamic import forms, which the [expr] and [structure] mappers
846+
rewrite before mapping their children, [await] on a module has no effect.
847+
Remove it, keeping its attributes on the module it wraps, so the type
848+
checker sees the same module expressions as without it: it treats some
849+
shapes specially, e.g. a module path in [module type of] or [()] as the
850+
argument of a generative functor. *)
851+
let module_expr_mapper (self : mapper) (me : Parsetree.module_expr) =
852+
let _, me = Ast_await.remove_awaits false me in
853+
default_mapper.module_expr self me
854+
879855
let mapper : mapper =
880856
{
881857
default_mapper with
858+
module_expr = module_expr_mapper;
882859
expr = expr_mapper ~async_context:(ref true) ~in_function_def:(ref false);
883860
pat = pat_mapper;
884861
typ = typ_mapper;

‎compiler/ml/ast_await.ml‎

Lines changed: 35 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
let is_await : Parsetree.attribute -> bool =
2-
fun ({txt}, _) -> txt = "await" || txt = "res.await"
3-
41
let create_await_expression (e : Parsetree.expression) =
52
let loc = {e.pexp_loc with loc_ghost = true} in
63
let unsafe_await =
@@ -28,13 +25,42 @@ let is_await_expr (e : Parsetree.expression) =
2825
true
2926
| _ -> false
3027

31-
(* Transform `@res.await M` to unpack(@res.await import(module(M: __M0__))) *)
28+
(* [m] without its outer awaits, e.g. [await (await M)], whose attributes
29+
(e.g. [@warning]) stay on the module they wrap, after its own as in the v0
30+
encoding, and whether it had any ([awaited] for the awaits already
31+
removed) *)
32+
let rec remove_awaits awaited (m : Parsetree.module_expr) =
33+
match m.pmod_desc with
34+
| Pmod_await inner ->
35+
remove_awaits true
36+
{inner with pmod_attributes = inner.pmod_attributes @ m.pmod_attributes}
37+
| _ -> (awaited, m)
38+
39+
(* An awaited module path: [await M], and [await (M: S)] or [(await M: S)],
40+
where [await] may be repeated, e.g. [await (await M)]. Returns the path of
41+
[M]; the module to import, which is [e] without its awaits, whose
42+
attributes (e.g. [@warning]) stay on the module they wrap; and [S] for the
43+
constrained forms. It is a dynamic import when [S] is absent or a module
44+
type path. *)
45+
let awaited_module_path (e : Parsetree.module_expr) =
46+
match remove_awaits false e with
47+
| true, ({pmod_desc = Pmod_ident lid} as imported) ->
48+
Some (lid, imported, None)
49+
| awaited, ({pmod_desc = Pmod_constraint (m, mty)} as constrained) -> (
50+
match remove_awaits awaited m with
51+
| true, ({pmod_desc = Pmod_ident lid} as path) ->
52+
Some
53+
( lid,
54+
{constrained with pmod_desc = Pmod_constraint (path, mty)},
55+
Some mty )
56+
| _ -> None)
57+
| _ -> None
58+
59+
(* Transform the dynamic import [e] of [imported], as returned by
60+
[awaited_module_path], to unpack(await import(module(M: __M0__))) *)
3261
let create_await_module_expression ~module_type_lid (e : Parsetree.module_expr)
33-
=
62+
imported =
3463
let open Ast_helper in
35-
let remove_await_attribute =
36-
List.filter (fun ((loc, _) : Parsetree.attribute) -> loc.txt != "res.await")
37-
in
3864
{
3965
e with
4066
pmod_desc =
@@ -50,12 +76,7 @@ let create_await_module_expression ~module_type_lid (e : Parsetree.module_expr)
5076
[
5177
( Nolabel,
5278
Exp.constraint_ ~loc:e.pmod_loc
53-
(Exp.pack ~loc:e.pmod_loc
54-
{
55-
e with
56-
pmod_attributes =
57-
remove_await_attribute e.pmod_attributes;
58-
})
79+
(Exp.pack ~loc:e.pmod_loc imported)
5980
(Typ.package ~loc:e.pmod_loc module_type_lid []) );
6081
]));
6182
}

‎compiler/ml/ast_helper.ml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,7 @@ module Mod = struct
288288
let constraint_ ?loc ?attrs m mty = mk ?loc ?attrs (Pmod_constraint (m, mty))
289289
let unpack ?loc ?attrs e = mk ?loc ?attrs (Pmod_unpack e)
290290
let extension ?loc ?attrs a = mk ?loc ?attrs (Pmod_extension a)
291+
let await ?loc ?attrs m = mk ?loc ?attrs (Pmod_await m)
291292
end
292293

293294
module Sig = struct

‎compiler/ml/ast_helper.mli‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,7 @@ module Mod : sig
418418
?loc:loc -> ?attrs:attrs -> module_expr -> module_type -> module_expr
419419
val unpack : ?loc:loc -> ?attrs:attrs -> expression -> module_expr
420420
val extension : ?loc:loc -> ?attrs:attrs -> extension -> module_expr
421+
val await : ?loc:loc -> ?attrs:attrs -> module_expr -> module_expr
421422
end
422423

423424
(** Signature items *)

‎compiler/ml/ast_iterator.ml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@ module M = struct
247247
sub.module_type sub mty
248248
| Pmod_unpack e -> sub.expr sub e
249249
| Pmod_extension x -> sub.extension sub x
250+
| Pmod_await m -> sub.module_expr sub m
250251

251252
let iter_structure_item sub {pstr_loc = loc; pstr_desc = desc} =
252253
sub.location sub loc;

‎compiler/ml/ast_mapper.ml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,7 @@ module M = struct
250250
constraint_ ~loc ~attrs (sub.module_expr sub m) (sub.module_type sub mty)
251251
| Pmod_unpack e -> unpack ~loc ~attrs (sub.expr sub e)
252252
| Pmod_extension x -> extension ~loc ~attrs (sub.extension sub x)
253+
| Pmod_await m -> await ~loc ~attrs (sub.module_expr sub m)
253254

254255
let map_structure_item sub {pstr_loc = loc; pstr_desc = desc} =
255256
let open Str in

0 commit comments

Comments
 (0)