@@ -1500,17 +1500,27 @@ and mapper =
1500
1500
in
1501
1501
{super with module_expr; structure_item; expr}
1502
1502
1503
+ let is_js_attribute txt = txt = " js" || has_prefix ~prefix: " js." txt
1504
+
1503
1505
let check_loc_mapper =
1504
1506
let mapper = Ast_mapper. default_mapper in
1505
1507
let attribute _this (({txt; loc} , _ ) as attr ) =
1506
- if txt = " js " || has_prefix ~prefix: " js. " txt then begin
1508
+ if is_js_attribute txt then begin
1507
1509
if is_registered_loc loc then ()
1508
1510
else error loc Spurious_attribute
1509
1511
end ;
1510
1512
attr
1511
1513
in
1512
1514
{ mapper with Ast_mapper. attribute }
1513
1515
1516
+ let clear_attr_mapper =
1517
+ let mapper = Ast_mapper. default_mapper in
1518
+ let attributes _this attrs =
1519
+ let f ({txt = _ ; loc} , _ ) = not (is_registered_loc loc) in
1520
+ List. filter f attrs
1521
+ in
1522
+ { mapper with Ast_mapper. attributes }
1523
+
1514
1524
(* * Main *)
1515
1525
1516
1526
let out = ref " "
@@ -1538,10 +1548,10 @@ let standalone () =
1538
1548
~tool_name: " gen_js_iface"
1539
1549
src
1540
1550
in
1541
- let res = str_of_sg ~global_attrs: [] sg in
1551
+ let str = str_of_sg ~global_attrs: [] sg in
1542
1552
ignore (check_loc_mapper.Ast_mapper. signature check_loc_mapper sg);
1543
- Format. fprintf ( Format. formatter_of_out_channel oc) " %a@. "
1544
- Pprintast. structure res ;
1553
+ let str = clear_attr_mapper. Ast_mapper. structure clear_attr_mapper str in
1554
+ Format. fprintf ( Format. formatter_of_out_channel oc) " %a@. " Pprintast. structure str ;
1545
1555
if ! out <> " -" then close_out oc
1546
1556
1547
1557
let () =
0 commit comments