Skip to content

Commit 538fdee

Browse files
committed
Restore original variant names.
1 parent 6f615bf commit 538fdee

32 files changed

+341
-304
lines changed

analysis/src/CompletionFrontEnd.ml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,8 @@ let rec exprToContextPathInner (e : Parsetree.expression) =
268268
(* Transform away pipe with apply call *)
269269
exprToContextPath
270270
{
271-
pexp_desc = Pexp_apply {funct = d; args = (Nolbl, lhs) :: args; partial};
271+
pexp_desc =
272+
Pexp_apply {funct = d; args = (Nolabel, lhs) :: args; partial};
272273
pexp_loc;
273274
pexp_attributes;
274275
}
@@ -288,7 +289,7 @@ let rec exprToContextPathInner (e : Parsetree.expression) =
288289
Pexp_apply
289290
{
290291
funct = {pexp_desc = Pexp_ident id; pexp_loc; pexp_attributes};
291-
args = [(Nolbl, lhs)];
292+
args = [(Nolabel, lhs)];
292293
partial;
293294
};
294295
pexp_loc;
@@ -1436,7 +1437,7 @@ let completionWithParser1 ~currentFile ~debug ~offset ~path ~posCursor
14361437
| Some (ctxPath, currentUnlabelledCount) ->
14371438
(processingFun :=
14381439
match lbl with
1439-
| Nolbl -> Some (ctxPath, currentUnlabelledCount + 1)
1440+
| Nolabel -> Some (ctxPath, currentUnlabelledCount + 1)
14401441
| _ -> Some (ctxPath, currentUnlabelledCount));
14411442
if Debug.verbose () then
14421443
print_endline "[expr_iter] Completing for argument value";
@@ -1446,10 +1447,10 @@ let completionWithParser1 ~currentFile ~debug ~offset ~path ~posCursor
14461447
functionContextPath = ctxPath;
14471448
argumentLabel =
14481449
(match lbl with
1449-
| Nolbl ->
1450+
| Nolabel ->
14501451
Unlabelled {argumentPosition = currentUnlabelledCount}
1451-
| Opt {txt = name} -> Optional name
1452-
| Lbl {txt = name} -> Labelled name);
1452+
| Optional {txt = name} -> Optional name
1453+
| Labelled {txt = name} -> Labelled name);
14531454
})
14541455
in
14551456
(match defaultExpOpt with

analysis/src/CompletionJsx.ml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -465,14 +465,15 @@ let extractJsxProps ~(compName : Longident.t Location.loc) ~args =
465465
in
466466
let rec processProps ~acc args =
467467
match args with
468-
| (Asttypes.Lbl {txt = "children"}, {Parsetree.pexp_loc}) :: _ ->
468+
| (Asttypes.Labelled {txt = "children"}, {Parsetree.pexp_loc}) :: _ ->
469469
{
470470
compName;
471471
props = List.rev acc;
472472
childrenStart =
473473
(if pexp_loc.loc_ghost then None else Some (Loc.start pexp_loc));
474474
}
475-
| ((Lbl {txt = s; loc} | Opt {txt = s; loc}), (eProp : Parsetree.expression))
475+
| ( (Labelled {txt = s; loc} | Optional {txt = s; loc}),
476+
(eProp : Parsetree.expression) )
476477
:: rest -> (
477478
let namedArgLoc = if loc = Location.none then None else Some loc in
478479
match namedArgLoc with

analysis/src/DumpAst.ml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -218,9 +218,9 @@ and printExprItem expr ~pos ~indentation =
218218
^ addIndentation (indentation + 1)
219219
^ "arg: "
220220
^ (match arg with
221-
| Nolbl -> "Nolabel"
222-
| Lbl {txt = name} -> "Labelled(" ^ name ^ ")"
223-
| Opt {txt = name} -> "Optional(" ^ name ^ ")")
221+
| Nolabel -> "Nolabel"
222+
| Labelled {txt = name} -> "Labelled(" ^ name ^ ")"
223+
| Optional {txt = name} -> "Optional(" ^ name ^ ")")
224224
^ ",\n"
225225
^ addIndentation (indentation + 2)
226226
^ "pattern: "

analysis/src/SemanticTokens.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ let command ~debug ~emitter ~path =
266266

267267
let posOfGreatherthanAfterProps =
268268
let rec loop = function
269-
| (Asttypes.Lbl {txt = "children"}, {Parsetree.pexp_loc}) :: _ ->
269+
| (Asttypes.Labelled {txt = "children"}, {Parsetree.pexp_loc}) :: _ ->
270270
Loc.start pexp_loc
271271
| _ :: args -> loop args
272272
| [] -> (* should not happen *) (-1, -1)

analysis/src/SharedTypes.ml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -898,7 +898,7 @@ type arg = {label: label; exp: Parsetree.expression}
898898
let extractExpApplyArgs ~args =
899899
let rec processArgs ~acc args =
900900
match args with
901-
| ( ((Asttypes.Lbl {txt = s; loc} | Opt {txt = s; loc}) as label),
901+
| ( ((Asttypes.Labelled {txt = s; loc} | Optional {txt = s; loc}) as label),
902902
(e : Parsetree.expression) )
903903
:: rest -> (
904904
let namedArgLoc = if loc = Location.none then None else Some loc in
@@ -909,15 +909,15 @@ let extractExpApplyArgs ~args =
909909
name = s;
910910
opt =
911911
(match label with
912-
| Opt _ -> true
912+
| Optional _ -> true
913913
| _ -> false);
914914
posStart = Loc.start loc;
915915
posEnd = Loc.end_ loc;
916916
}
917917
in
918918
processArgs ~acc:({label = Some labelled; exp = e} :: acc) rest
919919
| None -> processArgs ~acc rest)
920-
| (Nolbl, (e : Parsetree.expression)) :: rest ->
920+
| (Nolabel, (e : Parsetree.expression)) :: rest ->
921921
if e.pexp_loc.loc_ghost then processArgs ~acc rest
922922
else processArgs ~acc:({label = None; exp = e} :: acc) rest
923923
| [] -> List.rev acc

analysis/src/SignatureHelp.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ let extractParameters ~signature ~typeStrForParser ~labelPrefixLen =
130130
(* The AST locations does not account for "=?" of optional arguments, so add that to the offset here if needed. *)
131131
let endOffset =
132132
match argumentLabel with
133-
| Asttypes.Opt _ -> endOffset + 2
133+
| Asttypes.Optional _ -> endOffset + 2
134134
| _ -> endOffset
135135
in
136136
extractParams nextFunctionExpr

analysis/src/TypeUtils.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -941,7 +941,7 @@ module Codegen = struct
941941
let mkFailWithExp () =
942942
Ast_helper.Exp.apply
943943
(Ast_helper.Exp.ident {txt = Lident "failwith"; loc = Location.none})
944-
[(Nolbl, Ast_helper.Exp.constant (Pconst_string ("TODO", None)))]
944+
[(Nolabel, Ast_helper.Exp.constant (Pconst_string ("TODO", None)))]
945945

946946
let mkConstructPat ?payload name =
947947
Ast_helper.Pat.construct

analysis/src/Xform.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ module IfThenElse = struct
9595
Pexp_ident
9696
{txt = Longident.Lident (("==" | "!=") as op)};
9797
};
98-
args = [(Nolbl, arg1); (Nolbl, arg2)];
98+
args = [(Nolabel, arg1); (Nolabel, arg2)];
9999
};
100100
},
101101
e1,
@@ -300,7 +300,7 @@ module AddTypeAnnotation = struct
300300
match e.pexp_desc with
301301
| Pexp_fun {arg_label; lhs = pat; rhs = e} ->
302302
let isUnlabeledOnlyArg =
303-
argNum = 1 && arg_label = Nolbl
303+
argNum = 1 && arg_label = Nolabel
304304
&&
305305
match e.pexp_desc with
306306
| Pexp_fun _ -> false

compiler/frontend/ast_compatible.ml

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ open Parsetree
3131
let default_loc = Location.none
3232

3333
let arrow ?loc ?attrs ~arity a b =
34-
Ast_helper.Typ.arrow ?loc ?attrs ~arity Nolbl a b
34+
Ast_helper.Typ.arrow ?loc ?attrs ~arity Nolabel a b
3535

3636
let apply_simple ?(loc = default_loc) ?(attrs = []) (fn : expression)
3737
(args : expression list) : expression =
@@ -42,7 +42,7 @@ let apply_simple ?(loc = default_loc) ?(attrs = []) (fn : expression)
4242
Pexp_apply
4343
{
4444
funct = fn;
45-
args = Ext_list.map args (fun x -> (Asttypes.Nolbl, x));
45+
args = Ext_list.map args (fun x -> (Asttypes.Nolabel, x));
4646
partial = false;
4747
};
4848
}
@@ -51,7 +51,8 @@ let app1 ?(loc = default_loc) ?(attrs = []) fn arg1 : expression =
5151
{
5252
pexp_loc = loc;
5353
pexp_attributes = attrs;
54-
pexp_desc = Pexp_apply {funct = fn; args = [(Nolbl, arg1)]; partial = false};
54+
pexp_desc =
55+
Pexp_apply {funct = fn; args = [(Nolabel, arg1)]; partial = false};
5556
}
5657

5758
let app2 ?(loc = default_loc) ?(attrs = []) fn arg1 arg2 : expression =
@@ -60,7 +61,7 @@ let app2 ?(loc = default_loc) ?(attrs = []) fn arg1 arg2 : expression =
6061
pexp_attributes = attrs;
6162
pexp_desc =
6263
Pexp_apply
63-
{funct = fn; args = [(Nolbl, arg1); (Nolbl, arg2)]; partial = false};
64+
{funct = fn; args = [(Nolabel, arg1); (Nolabel, arg2)]; partial = false};
6465
}
6566

6667
let app3 ?(loc = default_loc) ?(attrs = []) fn arg1 arg2 arg3 : expression =
@@ -71,7 +72,7 @@ let app3 ?(loc = default_loc) ?(attrs = []) fn arg1 arg2 arg3 : expression =
7172
Pexp_apply
7273
{
7374
funct = fn;
74-
args = [(Nolbl, arg1); (Nolbl, arg2); (Nolbl, arg3)];
75+
args = [(Nolabel, arg1); (Nolabel, arg2); (Nolabel, arg3)];
7576
partial = false;
7677
};
7778
}
@@ -82,7 +83,14 @@ let fun_ ?(loc = default_loc) ?(attrs = []) ?(async = false) ~arity pat exp =
8283
pexp_attributes = attrs;
8384
pexp_desc =
8485
Pexp_fun
85-
{arg_label = Nolbl; default = None; lhs = pat; rhs = exp; arity; async};
86+
{
87+
arg_label = Nolabel;
88+
default = None;
89+
lhs = pat;
90+
rhs = exp;
91+
arity;
92+
async;
93+
};
8694
}
8795

8896
let const_exp_string ?(loc = default_loc) ?(attrs = []) ?delimiter (s : string)
@@ -111,7 +119,7 @@ let apply_labels ?(loc = default_loc) ?(attrs = []) fn
111119
funct = fn;
112120
args =
113121
Ext_list.map args (fun (l, a) ->
114-
(Asttypes.Lbl {txt = l; loc = Location.none}, a));
122+
(Asttypes.Labelled {txt = l; loc = Location.none}, a));
115123
partial = false;
116124
};
117125
}
@@ -120,7 +128,8 @@ let label_arrow ?(loc = default_loc) ?(attrs = []) ~arity txt arg ret :
120128
core_type =
121129
{
122130
ptyp_desc =
123-
Ptyp_arrow {lbl = Asttypes.Lbl {txt; loc = default_loc}; arg; ret; arity};
131+
Ptyp_arrow
132+
{lbl = Asttypes.Labelled {txt; loc = default_loc}; arg; ret; arity};
124133
ptyp_loc = loc;
125134
ptyp_attributes = attrs;
126135
}
@@ -129,7 +138,8 @@ let opt_arrow ?(loc = default_loc) ?(attrs = []) ~arity txt arg ret : core_type
129138
=
130139
{
131140
ptyp_desc =
132-
Ptyp_arrow {lbl = Asttypes.Opt {txt; loc = default_loc}; arg; ret; arity};
141+
Ptyp_arrow
142+
{lbl = Asttypes.Optional {txt; loc = default_loc}; arg; ret; arity};
133143
ptyp_loc = loc;
134144
ptyp_attributes = attrs;
135145
}

compiler/frontend/ast_core_type.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,5 +171,5 @@ let list_of_arrow (ty : t) : t * param_type list =
171171
let add_last_obj (ty : t) (obj : t) =
172172
let result, params = list_of_arrow ty in
173173
mk_fn_type
174-
(params @ [{label = Nolbl; ty = obj; attr = []; loc = obj.ptyp_loc}])
174+
(params @ [{label = Nolabel; ty = obj; attr = []; loc = obj.ptyp_loc}])
175175
result

compiler/frontend/ast_core_type_class_type.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ let typ_mapper (self : Bs_ast_mapper.mapper) (ty : Parsetree.core_type) =
106106
| Meth_callback attr, attrs -> (attrs, attr +> ty)
107107
in
108108
Ast_compatible.object_field name attrs
109-
(Ast_typ_uncurry.to_uncurry_type loc self Nolbl core_type
109+
(Ast_typ_uncurry.to_uncurry_type loc self Nolabel core_type
110110
(Ast_literal.type_unit ~loc ()))
111111
in
112112
let not_getter_setter ty =

compiler/frontend/ast_exp_apply.ml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@ let app_exp_mapper (e : exp) (self : Bs_ast_mapper.mapper) : exp =
9191
| Pexp_apply {funct = fn1; args; partial} ->
9292
Bs_ast_invariant.warn_discarded_unused_attributes fn1.pexp_attributes;
9393
{
94-
pexp_desc = Pexp_apply {funct = fn1; args = (Nolbl, a) :: args; partial};
94+
pexp_desc =
95+
Pexp_apply {funct = fn1; args = (Nolabel, a) :: args; partial};
9596
pexp_loc = e.pexp_loc;
9697
pexp_attributes = e.pexp_attributes @ f.pexp_attributes;
9798
}
@@ -115,7 +116,7 @@ let app_exp_mapper (e : exp) (self : Bs_ast_mapper.mapper) : exp =
115116
Pexp_apply
116117
{
117118
funct = fn;
118-
args = (Nolbl, bounded_obj_arg) :: args;
119+
args = (Nolabel, bounded_obj_arg) :: args;
119120
partial = false;
120121
};
121122
pexp_attributes = [];
@@ -169,7 +170,7 @@ let app_exp_mapper (e : exp) (self : Bs_ast_mapper.mapper) : exp =
169170
let arg = self.expr self arg in
170171
let fn = Exp.send ~loc obj {txt = name ^ Literals.setter_suffix; loc} in
171172
Exp.constraint_ ~loc
172-
(Exp.apply ~loc fn [(Nolbl, arg)])
173+
(Exp.apply ~loc fn [(Nolabel, arg)])
173174
(Ast_literal.type_unit ~loc ())
174175
in
175176
match obj.pexp_desc with

compiler/frontend/ast_exp_extension.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ let handle_extension e (self : Bs_ast_mapper.mapper)
4545
Exp.apply ~loc
4646
(Exp.ident ~loc {txt = Longident.parse "Js.Exn.raiseError"; loc})
4747
[
48-
( Nolbl,
48+
( Nolabel,
4949
Exp.constant ~loc
5050
(Pconst_string
5151
( (pretext

compiler/frontend/ast_exp_handle_external.ml

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ let handle_external loc (x : string) : Parsetree.expression =
4343
str_exp with
4444
pexp_desc =
4545
Ast_external_mk.local_external_apply loc ~pval_prim:["#raw_expr"]
46-
~pval_type:(Typ.arrow ~arity:(Some 1) Nolbl (Typ.any ()) (Typ.any ()))
46+
~pval_type:
47+
(Typ.arrow ~arity:(Some 1) Nolabel (Typ.any ()) (Typ.any ()))
4748
[str_exp];
4849
}
4950
in
@@ -69,7 +70,8 @@ let handle_debugger loc (payload : Ast_payload.t) =
6970
| PStr [] ->
7071
Ast_external_mk.local_external_apply loc ~pval_prim:["%debugger"]
7172
~pval_type:
72-
(Typ.arrow ~arity:(Some 1) Nolbl (Typ.any ()) (Ast_literal.type_unit ()))
73+
(Typ.arrow ~arity:(Some 1) Nolabel (Typ.any ())
74+
(Ast_literal.type_unit ()))
7375
[Ast_literal.val_unit ~loc ()]
7476
| _ ->
7577
Location.raise_errorf ~loc "%%debugger extension doesn't accept arguments"
@@ -93,7 +95,8 @@ let handle_raw ~kind loc payload =
9395
exp with
9496
pexp_desc =
9597
Ast_external_mk.local_external_apply loc ~pval_prim:["#raw_expr"]
96-
~pval_type:(Typ.arrow ~arity:(Some 1) Nolbl (Typ.any ()) (Typ.any ()))
98+
~pval_type:
99+
(Typ.arrow ~arity:(Some 1) Nolabel (Typ.any ()) (Typ.any ()))
97100
[exp];
98101
pexp_attributes =
99102
(match !is_function with
@@ -120,11 +123,11 @@ let handle_ffi ~loc ~payload =
120123
let any = Ast_helper.Typ.any ~loc:e.pexp_loc () in
121124
let unit = Ast_literal.type_unit ~loc () in
122125
let rec arrow ~arity =
123-
if arity = 0 then Ast_helper.Typ.arrow ~arity:None ~loc Nolbl unit any
126+
if arity = 0 then Ast_helper.Typ.arrow ~arity:None ~loc Nolabel unit any
124127
else if arity = 1 then
125-
Ast_helper.Typ.arrow ~arity:None ~loc Nolbl any any
128+
Ast_helper.Typ.arrow ~arity:None ~loc Nolabel any any
126129
else
127-
Ast_helper.Typ.arrow ~loc ~arity:None Nolbl any
130+
Ast_helper.Typ.arrow ~loc ~arity:None Nolabel any
128131
(arrow ~arity:(arity - 1))
129132
in
130133
match !is_function with
@@ -143,7 +146,7 @@ let handle_ffi ~loc ~payload =
143146
pexp_desc =
144147
Ast_external_mk.local_external_apply loc ~pval_prim:["#raw_expr"]
145148
~pval_type:
146-
(Typ.arrow ~arity:(Some 1) Nolbl (Typ.any ()) (Typ.any ()))
149+
(Typ.arrow ~arity:(Some 1) Nolabel (Typ.any ()) (Typ.any ()))
147150
[exp];
148151
pexp_attributes =
149152
(match !is_function with
@@ -160,7 +163,7 @@ let handle_raw_structure loc payload =
160163
pexp_desc =
161164
Ast_external_mk.local_external_apply loc ~pval_prim:["#raw_stmt"]
162165
~pval_type:
163-
(Typ.arrow ~arity:(Some 1) Nolbl (Typ.any ()) (Typ.any ()))
166+
(Typ.arrow ~arity:(Some 1) Nolabel (Typ.any ()) (Typ.any ()))
164167
[exp];
165168
}
166169
| None ->

0 commit comments

Comments
 (0)