@@ -221,17 +221,40 @@ let expr_mapper ~async_context ~in_function_def (self : mapper)
221
221
the attribute to the whole expression, in general, when shuffuling the ast
222
222
it is very hard to place attributes correctly
223
223
*)
224
+ (* module M = await Belt.List *)
224
225
| Pexp_letmodule
225
226
(lid, ({pmod_desc = Pmod_ident {txt}; pmod_attributes} as me), expr)
226
227
when Res_parsetree_viewer. hasAwaitAttribute pmod_attributes ->
227
- let safe_module_type_name = local_module_type_name txt in
228
+ let safe_module_type_lid : Ast_helper.lid =
229
+ {txt = Lident (local_module_type_name txt); loc = me.pmod_loc}
230
+ in
228
231
{
229
232
e with
230
233
pexp_desc =
231
234
Pexp_letmodule
232
235
( lid,
233
236
Ast_await. create_await_module_expression
234
- ~module_type_name: safe_module_type_name me,
237
+ ~module_type_lid: safe_module_type_lid me,
238
+ expr );
239
+ }
240
+ (* module M = await (Belt.List: BeltList) *)
241
+ | Pexp_letmodule
242
+ ( lid,
243
+ ({
244
+ pmod_desc =
245
+ Pmod_constraint
246
+ ({pmod_desc = Pmod_ident _}, {pmty_desc = Pmty_ident mtyp_lid});
247
+ pmod_attributes;
248
+ } as me),
249
+ expr )
250
+ when Res_parsetree_viewer. hasAwaitAttribute pmod_attributes ->
251
+ {
252
+ e with
253
+ pexp_desc =
254
+ Pexp_letmodule
255
+ ( lid,
256
+ Ast_await. create_await_module_expression ~module_type_lid: mtyp_lid
257
+ me,
235
258
expr );
236
259
}
237
260
| _ -> default_expr_mapper self e
@@ -531,6 +554,9 @@ let rec structure_mapper ~await_context (self : mapper) (stru : Ast_structure.t)
531
554
~typ: (Mty. typeof_ ~loc me));
532
555
]
533
556
in
557
+ let safe_module_type_lid : Ast_helper.lid =
558
+ {txt = Lident safe_module_type_name; loc = mb.pmb_expr.pmod_loc}
559
+ in
534
560
module_type_decl
535
561
@ (* module M = @res.await Belt.List *)
536
562
{
@@ -541,7 +567,7 @@ let rec structure_mapper ~await_context (self : mapper) (stru : Ast_structure.t)
541
567
mb with
542
568
pmb_expr =
543
569
Ast_await. create_await_module_expression
544
- ~module_type_name: safe_module_type_name mb.pmb_expr;
570
+ ~module_type_lid: safe_module_type_lid mb.pmb_expr;
545
571
};
546
572
}
547
573
:: structure_mapper ~await_context self rest
0 commit comments