Skip to content

Commit 7d4b94a

Browse files
committed
clean up
1 parent 1ed974f commit 7d4b94a

File tree

1 file changed

+23
-26
lines changed

1 file changed

+23
-26
lines changed

jscomp/frontend/bs_builtin_ppx.ml

+23-26
Original file line numberDiff line numberDiff line change
@@ -573,39 +573,36 @@ let rec structure_mapper ~await_context (self : mapper) (stru : Ast_structure.t)
573573
:: structure_mapper ~await_context self rest
574574
| Pstr_value (_, vbs) ->
575575
let item = self.structure_item self item in
576-
let module_exprs =
576+
(* [ module __Belt_List__ = module type of Belt.List ] *)
577+
let module_type_decls =
577578
vbs
578579
|> List.filter_map (fun ({pvb_expr} : Parsetree.value_binding) ->
579580
match pvb_expr.pexp_desc with
580581
| Pexp_letmodule (_, ({pmod_attributes} as me), _)
581-
when Res_parsetree_viewer.hasAwaitAttribute pmod_attributes ->
582-
Some me
583-
| _ -> None)
584-
in
585-
(* [ module __Belt_List__ = module type of Belt.List ] *)
586-
let module_type_decls =
587-
module_exprs
588-
|> List.filter_map (fun ({pmod_desc} as me : Parsetree.module_expr) ->
589-
match pmod_desc with
590-
| Pmod_ident {txt; loc} -> (
591-
let safe_module_type_name = local_module_type_name txt in
592-
let has_local_module_name =
593-
Hashtbl.find_opt !await_context safe_module_type_name
594-
in
582+
when Res_parsetree_viewer.hasAwaitAttribute pmod_attributes
583+
-> (
584+
match me.pmod_desc with
585+
| Pmod_ident {txt; loc} -> (
586+
let safe_module_type_name = local_module_type_name txt in
587+
let has_local_module_name =
588+
Hashtbl.find_opt !await_context safe_module_type_name
589+
in
595590

596-
match has_local_module_name with
597-
| Some _ -> None
598-
| None ->
599-
Hashtbl.add !await_context safe_module_type_name
600-
safe_module_type_name;
601-
Some
602-
Ast_helper.(
603-
Str.modtype ~loc
604-
(Mtd.mk ~loc
605-
{txt = safe_module_type_name; loc}
606-
~typ:(Mty.typeof_ ~loc me))))
591+
match has_local_module_name with
592+
| Some _ -> None
593+
| None ->
594+
Hashtbl.add !await_context safe_module_type_name
595+
safe_module_type_name;
596+
Some
597+
Ast_helper.(
598+
Str.modtype ~loc
599+
(Mtd.mk ~loc
600+
{txt = safe_module_type_name; loc}
601+
~typ:(Mty.typeof_ ~loc me))))
602+
| _ -> None)
607603
| _ -> None)
608604
in
605+
609606
module_type_decls @ (item :: structure_mapper ~await_context self rest)
610607
| _ ->
611608
self.structure_item self item :: structure_mapper ~await_context self rest

0 commit comments

Comments
 (0)