Skip to content

Commit d840939

Browse files
committed
changed to not recycle loc unintentinonlly
1 parent 409dbdb commit d840939

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

jscomp/frontend/ast_derive_projector.ml

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,12 @@ let init () =
1919
Ast_derive_util.core_type_of_type_declaration tdcl
2020
in
2121
let gentype_attrs =
22-
Ext_list.filter core_type.ptyp_attributes
23-
Ast_attributes.is_gentype
22+
match
23+
Ext_list.exists core_type.ptyp_attributes
24+
Ast_attributes.is_gentype
25+
with
26+
| true -> Some [Ast_attributes.gentype]
27+
| false -> None
2428
in
2529
match tdcl.ptype_kind with
2630
| Ptype_record label_declarations ->
@@ -30,7 +34,7 @@ let init () =
3034
Parsetree.label_declaration)
3135
->
3236
let txt = "param" in
33-
Ast_comb.single_non_rec_value ~attrs:gentype_attrs pld_name
37+
Ast_comb.single_non_rec_value ?attrs:gentype_attrs pld_name
3438
(Ast_compatible.fun_
3539
(Pat.constraint_ (Pat.var {txt; loc}) core_type)
3640
(Exp.field
@@ -61,7 +65,7 @@ let init () =
6165
| None -> core_type
6266
| Some x -> x
6367
in
64-
Ast_comb.single_non_rec_value ~attrs:gentype_attrs
68+
Ast_comb.single_non_rec_value ?attrs:gentype_attrs
6569
{loc; txt = little_con_name}
6670
(if arity = 0 then
6771
(*TODO: add a prefix, better inter-op with FFI *)
@@ -104,13 +108,17 @@ let init () =
104108
Ast_derive_util.core_type_of_type_declaration tdcl
105109
in
106110
let gentype_attrs =
107-
Ext_list.filter core_type.ptyp_attributes
108-
Ast_attributes.is_gentype
111+
match
112+
Ext_list.exists core_type.ptyp_attributes
113+
Ast_attributes.is_gentype
114+
with
115+
| true -> Some [Ast_attributes.gentype]
116+
| false -> None
109117
in
110118
match tdcl.ptype_kind with
111119
| Ptype_record label_declarations ->
112120
Ext_list.map label_declarations (fun {pld_name; pld_type} ->
113-
Ast_comb.single_non_rec_val ~attrs:gentype_attrs pld_name
121+
Ast_comb.single_non_rec_val ?attrs:gentype_attrs pld_name
114122
(Ast_compatible.arrow core_type pld_type))
115123
| Ptype_variant constructor_declarations ->
116124
Ext_list.map constructor_declarations
@@ -132,7 +140,7 @@ let init () =
132140
| Some x -> x
133141
| None -> core_type
134142
in
135-
Ast_comb.single_non_rec_val ~attrs:gentype_attrs
143+
Ast_comb.single_non_rec_val ?attrs:gentype_attrs
136144
{loc; txt = Ext_string.uncapitalize_ascii con_name}
137145
(Ext_list.fold_right pcd_args annotate_type (fun x acc ->
138146
Ast_compatible.arrow x acc)))

0 commit comments

Comments
 (0)