Skip to content

Commit 5011b3d

Browse files
committed
remove legacy code dealing with arg_label
1 parent 432f750 commit 5011b3d

18 files changed

+244
-318
lines changed

jscomp/main/native_ppx_main.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ let expr_mapper (self : mapper) ( e : Parsetree.expression) =
3939
(s, (Some delim)))
4040
->
4141
Ast_utf8_string_interp.transform e s delim
42-
| Pexp_fun (arg_label, _, pat , body)
43-
when Ast_compatible.is_arg_label_simple arg_label ->
42+
| Pexp_fun (Nolabel, _, pat , body)
43+
->
4444
begin match Ext_list.exclude_with_val
4545
e.pexp_attributes
4646
Ast_attributes.is_bs with

jscomp/syntax/ast_compatible.ml

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,10 @@ let default_loc = Location.none
3030

3131
type poly_var_label = Asttypes.label Asttypes.loc
3232

33-
type arg_label = Asttypes.arg_label =
34-
| Nolabel
35-
| Labelled of string
36-
| Optional of string
3733

38-
let is_arg_label_simple (s : arg_label) = s = (Nolabel : arg_label)
39-
type label = arg_label
34+
35+
36+
4037

4138

4239

@@ -46,13 +43,14 @@ let arrow ?(loc=default_loc) ?(attrs = []) a b =
4643
let apply_simple
4744
?(loc = default_loc)
4845
?(attrs = [])
49-
fn args : expression =
46+
(fn : expression)
47+
(args : expression list) : expression =
5048
{ pexp_loc = loc;
5149
pexp_attributes = attrs;
5250
pexp_desc =
5351
Pexp_apply(
5452
fn,
55-
(Ext_list.map args (fun x -> Nolabel, x) ) ) }
53+
(Ext_list.map args (fun x -> Asttypes.Nolabel, x) ) ) }
5654

5755
let app1
5856
?(loc = default_loc)
@@ -242,7 +240,7 @@ let const_exp_string_list_as_array xs =
242240
(Ext_list.map xs (fun x -> const_exp_string x ) )
243241

244242
type param_type =
245-
{label : arg_label ;
243+
{label : Asttypes.arg_label ;
246244
ty : Parsetree.core_type ;
247245
attr :Parsetree.attributes;
248246
loc : loc
@@ -273,4 +271,4 @@ let hash_label (x : poly_var_label) : int = Ext_pervasives.hash_variant x.txt
273271
let label_of_name (x : poly_var_label) : string = x.txt
274272

275273
type args =
276-
(arg_label * Parsetree.expression) list
274+
(Asttypes.arg_label * Parsetree.expression) list

jscomp/syntax/ast_compatible.mli

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@
2424

2525

2626
type poly_var_label = Asttypes.label Asttypes.loc
27-
type arg_label = Asttypes.arg_label
28-
type label = arg_label
27+
2928

3029

3130

@@ -110,19 +109,16 @@ val fun_ :
110109
expression ->
111110
expression
112111

113-
val opt_label : string -> arg_label
112+
val opt_label : string -> Asttypes.arg_label
114113

115114
val label_fun :
116115
?loc:Location.t ->
117116
?attrs:attrs ->
118-
label:arg_label ->
117+
label:Asttypes.arg_label ->
119118
pattern ->
120119
expression ->
121120
expression
122121

123-
val is_arg_label_simple :
124-
arg_label -> bool
125-
126122
val arrow :
127123
?loc:Location.t ->
128124
?attrs:attrs ->
@@ -180,7 +176,7 @@ val rec_type_sig:
180176
signature_item
181177

182178
type param_type =
183-
{label : arg_label ;
179+
{label : Asttypes.arg_label ;
184180
ty : Parsetree.core_type ;
185181
attr :Parsetree.attributes;
186182
loc : loc
@@ -199,4 +195,4 @@ val hash_label : poly_var_label -> int
199195
val label_of_name : poly_var_label -> string
200196

201197
type args =
202-
(arg_label * Parsetree.expression) list
198+
(Asttypes.arg_label * Parsetree.expression) list

jscomp/syntax/ast_core_type.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,8 @@ let rec get_uncurry_arity_aux (ty : t) acc =
141141
*)
142142
let get_uncurry_arity (ty : t ) =
143143
match ty.ptyp_desc with
144-
| Ptyp_arrow(arg_label, {ptyp_desc = (Ptyp_constr ({txt = Lident "unit"}, []))},
145-
rest ) when Ast_compatible.is_arg_label_simple arg_label ->
144+
| Ptyp_arrow(Nolabel, {ptyp_desc = (Ptyp_constr ({txt = Lident "unit"}, []))},
145+
rest ) ->
146146
begin match rest with
147147
| {ptyp_desc = Ptyp_arrow _ } ->
148148
`Arity (get_uncurry_arity_aux rest 1 )

jscomp/syntax/ast_exp_apply.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ let default_expr_mapper = Bs_ast_mapper.default_mapper.expr
4545

4646
let check_and_discard (args : Ast_compatible.args) =
4747
Ext_list.map args (fun (label,x) ->
48-
if not (Ast_compatible.is_arg_label_simple label) then
48+
if label <> Nolabel then
4949
Bs_syntaxerr.err x.pexp_loc Label_in_uncurried_bs_attribute;
5050
x
5151
)

jscomp/syntax/ast_exp_extension.ml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ let rec unroll_function_aux
3131
| Pexp_constant(
3232
Pconst_string
3333
(block,_)) -> acc, block
34-
| Pexp_fun(arg_label,_,pat,cont)
35-
when Ast_compatible.is_arg_label_simple arg_label ->
34+
| Pexp_fun(Nolabel,_,pat,cont)
35+
->
3636
(match pat.ppat_desc with
3737
| Ppat_var s ->
3838
unroll_function_aux (s.txt::acc) cont
@@ -69,8 +69,7 @@ let handle_extension record_as_js_object e (self : Bs_ast_mapper.mapper)
6969
| "bs.raw" | "raw" ->
7070
begin match payload with
7171
| PStr [
72-
{pstr_desc = Pstr_eval({pexp_desc = Pexp_fun(arg_label,_,pat,body)},_)}]
73-
when Ast_compatible.is_arg_label_simple arg_label
72+
{pstr_desc = Pstr_eval({pexp_desc = Pexp_fun(Nolabel,_,pat,body)},_)}]
7473
->
7574
begin match pat.ppat_desc, body.pexp_desc with
7675
| Ppat_construct ({txt = Lident "()"}, None), Pexp_constant(

jscomp/syntax/ast_external_mk.ml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@
2424

2525
let local_external_apply loc
2626
?(pval_attributes=[])
27-
~pval_prim
28-
~pval_type
27+
~(pval_prim : string list)
28+
~(pval_type : Parsetree.core_type)
2929
?(local_module_name = "J")
3030
?(local_fun_name = "unsafe_expr")
31-
args
31+
(args : Parsetree.expression list)
3232
: Parsetree.expression_desc =
3333
Pexp_letmodule
3434
({txt = local_module_name; loc},

jscomp/syntax/ast_pat.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ let arity_of_fun
4141
(e : Parsetree.expression) =
4242
let rec aux (e : Parsetree.expression) =
4343
match e.pexp_desc with
44-
| Pexp_fun (arg_label, _, pat, e)
45-
when Ast_compatible.is_arg_label_simple arg_label ->
44+
| Pexp_fun (Nolabel, _, pat, e)
45+
->
4646
1 + aux e
4747
| Pexp_fun _
4848
-> Location.raise_errorf

jscomp/syntax/ast_util.ml

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ type uncurry_expression_gen =
3232
Parsetree.expression ->
3333
Parsetree.expression_desc) cxt
3434
type uncurry_type_gen =
35-
(Ast_compatible.arg_label ->
35+
(Asttypes.arg_label ->
3636
Parsetree.core_type ->
3737
Parsetree.core_type ->
3838
Parsetree.core_type) cxt
@@ -165,10 +165,10 @@ let method_apply loc self obj name args =
165165
generic_apply `Method loc self obj args
166166
(fun loc obj -> Exp.mk ~loc (js_property loc obj name))
167167

168-
let generic_to_uncurry_type kind loc (mapper : Bs_ast_mapper.mapper) label
168+
let generic_to_uncurry_type kind loc (mapper : Bs_ast_mapper.mapper) (label : Asttypes.arg_label)
169169
(first_arg : Parsetree.core_type)
170170
(typ : Parsetree.core_type) =
171-
if not (Ast_compatible.is_arg_label_simple label) then
171+
if label <> Nolabel then
172172
Bs_syntaxerr.err loc Label_in_uncurried_bs_attribute;
173173

174174
let rec aux acc (typ : Parsetree.core_type) =
@@ -182,7 +182,7 @@ let generic_to_uncurry_type kind loc (mapper : Bs_ast_mapper.mapper) label
182182
begin match typ.ptyp_desc with
183183
| Ptyp_arrow (label, arg, body)
184184
->
185-
if not (Ast_compatible.is_arg_label_simple label) then
185+
if label <> Nolabel then
186186
Bs_syntaxerr.err typ.ptyp_loc Label_in_uncurried_bs_attribute;
187187
aux (mapper.typ mapper arg :: acc) body
188188
| _ -> mapper.typ mapper typ, acc
@@ -226,7 +226,7 @@ let generic_to_uncurry_exp kind loc (self : Bs_ast_mapper.mapper) pat body
226226
begin match body.pexp_desc with
227227
| Pexp_fun (arg_label,_, arg, body)
228228
->
229-
if not (Ast_compatible.is_arg_label_simple arg_label) then
229+
if arg_label <> Nolabel then
230230
Bs_syntaxerr.err loc Label_in_uncurried_bs_attribute;
231231
aux (self.pat self arg :: acc) body
232232
| _ -> self.expr self body, acc
@@ -469,9 +469,8 @@ let ocaml_obj_as_js_object
469469
->
470470
begin match e.pexp_desc with
471471
| Pexp_poly
472-
(({pexp_desc = Pexp_fun (arg_label, _, pat, e)} ),
472+
(({pexp_desc = Pexp_fun (Nolabel, _, pat, e)} ),
473473
None)
474-
when Ast_compatible.is_arg_label_simple arg_label
475474
->
476475
let arity = Ast_pat.arity_of_fun pat e in
477476
let method_type =
@@ -533,9 +532,8 @@ let ocaml_obj_as_js_object
533532
->
534533
begin match e.pexp_desc with
535534
| Pexp_poly
536-
(({pexp_desc = Pexp_fun (arg_label, None, pat, e)} as f),
535+
(({pexp_desc = Pexp_fun (Nolabel, None, pat, e)} as f),
537536
None)
538-
when Ast_compatible.is_arg_label_simple arg_label
539537
->
540538
let arity = Ast_pat.arity_of_fun pat e in
541539
let alias_type =

jscomp/syntax/ast_util.mli

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ type uncurry_expression_gen =
3838
Parsetree.expression ->
3939
Parsetree.expression_desc) cxt
4040
type uncurry_type_gen =
41-
(Ast_compatible.arg_label -> (* label for error checking *)
41+
(Asttypes.arg_label -> (* label for error checking *)
4242
Parsetree.core_type ->
4343
Parsetree.core_type ->
4444
Parsetree.core_type) cxt

0 commit comments

Comments
 (0)