Skip to content

Commit c3c2d08

Browse files
filipeomfacebook-github-bot
authored andcommitted
Rename effect to effect_ as it is a reserver keyword in OCaml 5.3 (#9268)
Summary: Fixes #9267 I don't know if any necessary adjustments need to be made to the documentation. We're changing the names of a few types and some labeled arguments, do the docs need to be updated anywhere? Also, my editor runs `ocamlformat` when I save a file, so the diff might be larger because of that. Let me know if the formatting changes are unwanted, and I can remove them from the commit. Pull Request resolved: #9268 Reviewed By: panagosg7 Differential Revision: D71492904 Pulled By: SamChou19815 fbshipit-source-id: 117e80c52194040b7428c0726215c725334f384e
1 parent 6527d55 commit c3c2d08

38 files changed

+241
-235
lines changed

src/analysis/env_builder/find_providers.ml

+3-3
Original file line numberDiff line numberDiff line change
@@ -605,7 +605,7 @@ end = struct
605605
tparams;
606606
async = _;
607607
generator = _;
608-
effect = _;
608+
effect_ = _;
609609
sig_loc = _;
610610
comments = _;
611611
} =
@@ -881,7 +881,7 @@ end = struct
881881
tparams;
882882
async = _;
883883
generator = _;
884-
effect = _;
884+
effect_ = _;
885885
sig_loc = _;
886886
comments = _;
887887
} =
@@ -921,7 +921,7 @@ end = struct
921921
tparams;
922922
async = _;
923923
generator = _;
924-
effect = _;
924+
effect_ = _;
925925
sig_loc = _;
926926
comments = _;
927927
} =

src/analysis/env_builder/name_def.ml

+8-7
Original file line numberDiff line numberDiff line change
@@ -1135,7 +1135,8 @@ class def_finder ~autocomplete_hooks ~react_jsx env_info toplevel_scope =
11351135

11361136
method! function_param (loc, _) = fail loc "Should be visited by visit_function_param"
11371137

1138-
method private visit_function_param ~hints ~effect (param : ('loc, 'loc) Ast.Function.Param.t) =
1138+
method private visit_function_param ~hints ~effect_ (param : ('loc, 'loc) Ast.Function.Param.t)
1139+
=
11391140
let open Ast.Function.Param in
11401141
let (loc, { argument; default = default_expression }) = param in
11411142
let optional =
@@ -1161,7 +1162,7 @@ class def_finder ~autocomplete_hooks ~react_jsx env_info toplevel_scope =
11611162
optional;
11621163
has_default_expression = Base.Option.is_some default_expression;
11631164
react_deep_read_only =
1164-
( if effect = Ast.Function.Hook then
1165+
( if effect_ = Ast.Function.Hook then
11651166
Some Hook
11661167
else
11671168
None
@@ -1215,7 +1216,7 @@ class def_finder ~autocomplete_hooks ~react_jsx env_info toplevel_scope =
12151216
ignore @@ super#function_param (loc, { argument; default = None })
12161217

12171218
method private visit_function_rest_param
1218-
~hints ~effect (expr : ('loc, 'loc) Ast.Function.RestParam.t) =
1219+
~hints ~effect_ (expr : ('loc, 'loc) Ast.Function.RestParam.t) =
12191220
let open Ast.Function.RestParam in
12201221
let (_, { argument; comments = _ }) = expr in
12211222
let (param_loc, _) = argument in
@@ -1228,7 +1229,7 @@ class def_finder ~autocomplete_hooks ~react_jsx env_info toplevel_scope =
12281229
optional = false;
12291230
has_default_expression = false;
12301231
react_deep_read_only =
1231-
( if effect = Ast.Function.Hook then
1232+
( if effect_ = Ast.Function.Hook then
12321233
Some Hook
12331234
else
12341235
None
@@ -1694,7 +1695,7 @@ class def_finder ~autocomplete_hooks ~react_jsx env_info toplevel_scope =
16941695
body;
16951696
async;
16961697
generator;
1697-
effect;
1698+
effect_;
16981699
predicate;
16991700
return;
17001701
tparams = fun_tparams;
@@ -1710,13 +1711,13 @@ class def_finder ~autocomplete_hooks ~react_jsx env_info toplevel_scope =
17101711
Base.List.iteri
17111712
~f:(fun i ->
17121713
this#visit_function_param
1713-
~effect
1714+
~effect_
17141715
~hints:(decompose_hints (Decomp_FuncParam (param_str_list, i, pred)) func_hints))
17151716
params_list;
17161717
Base.Option.iter
17171718
~f:
17181719
(this#visit_function_rest_param
1719-
~effect
1720+
~effect_
17201721
~hints:(decompose_hints (Decomp_FuncRest (param_str_list, pred)) func_hints)
17211722
)
17221723
rest;

src/analysis/property_assignment.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ let eval_property_assignment class_body =
260260
params = _;
261261
async = _;
262262
generator = _;
263-
effect = _;
263+
effect_ = _;
264264
predicate = _;
265265
return = _;
266266
tparams = _;

src/analysis/scope_builder.ml

+3-3
Original file line numberDiff line numberDiff line change
@@ -787,7 +787,7 @@ module Make (L : Loc_sig.S) (Api : Scope_api_sig.S with module L = L) :
787787
tparams;
788788
async = _;
789789
generator;
790-
effect = _;
790+
effect_ = _;
791791
predicate;
792792
sig_loc = _;
793793
comments = _;
@@ -840,7 +840,7 @@ module Make (L : Loc_sig.S) (Api : Scope_api_sig.S with module L = L) :
840840
tparams;
841841
async = _;
842842
generator;
843-
effect = _;
843+
effect_ = _;
844844
predicate;
845845
sig_loc = _;
846846
comments = _;
@@ -906,7 +906,7 @@ module Make (L : Loc_sig.S) (Api : Scope_api_sig.S with module L = L) :
906906
params = (_, { Params.this_; params = ps; rest = rpo; comments = _ });
907907
return;
908908
tparams;
909-
effect = _;
909+
effect_ = _;
910910
comments = _;
911911
} =
912912
ft

src/common/ty/ty_serializer.ml

+2-2
Original file line numberDiff line numberDiff line change
@@ -295,14 +295,14 @@ let type_ options =
295295
let return = fun_return_t f.fun_return in
296296
let params = fun_params f.fun_params f.fun_rest_param in
297297
let tparams = Base.Option.map ~f:type_params f.fun_type_params in
298-
let effect =
298+
let effect_ =
299299
match f.fun_effect with
300300
| Ty.Arbitrary -> Ast.Function.Arbitrary
301301
| Ty.Hook -> Ast.Function.Hook
302302
| Ty.Parametric n -> Ast.Function.Parametric n
303303
| Ty.Idempotent -> Ast.Function.Idempotent
304304
in
305-
{ T.Function.params; return; tparams; effect; comments = None }
305+
{ T.Function.params; return; tparams; effect_; comments = None }
306306
and fun_params params rest_param =
307307
let params = Base.List.map ~f:fun_param params in
308308
let rest = Base.Option.map ~f:fun_rest_param rest_param in

src/parser/declaration_parser.ml

+4-4
Original file line numberDiff line numberDiff line change
@@ -310,11 +310,11 @@ module Declaration (Parse : Parser_common.PARSER) (Type : Parser_common.TYPE) :
310310
let _function =
311311
with_loc (fun env ->
312312
let (async, leading_async) = async env in
313-
let (sig_loc, (generator, effect, tparams, id, params, return, predicate, leading)) =
313+
let (sig_loc, (generator, effect_, tparams, id, params, return, predicate, leading)) =
314314
with_loc
315315
(fun env ->
316316
let leading_function = Peek.comments env in
317-
let (effect, (generator, leading_generator)) =
317+
let (effect_, (generator, leading_generator)) =
318318
match Peek.token env with
319319
| T_FUNCTION ->
320320
Eat.token env;
@@ -372,7 +372,7 @@ module Declaration (Parse : Parser_common.PARSER) (Type : Parser_common.TYPE) :
372372
| None -> (return_annotation_remove_trailing env return, predicate)
373373
| Some _ -> (return, predicate_remove_trailing env predicate)
374374
in
375-
(generator, effect, tparams, id, params, return, predicate, leading))
375+
(generator, effect_, tparams, id, params, return, predicate, leading))
376376
env
377377
in
378378
let simple_params = is_simple_parameter_list params in
@@ -386,7 +386,7 @@ module Declaration (Parse : Parser_common.PARSER) (Type : Parser_common.TYPE) :
386386
params;
387387
body;
388388
generator;
389-
effect;
389+
effect_;
390390
async;
391391
predicate;
392392
return;

src/parser/estree_translator.ml

+8-8
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ with type t = Impl.t = struct
426426
{
427427
Function.params = (_, { Function.Params.comments = params_comments; _ }) as params;
428428
async;
429-
effect = _;
429+
effect_ = _;
430430
predicate = predicate_;
431431
tparams;
432432
return;
@@ -804,7 +804,7 @@ with type t = Impl.t = struct
804804
params = (_, { Function.Params.comments = params_comments; _ }) as params;
805805
async;
806806
generator;
807-
effect;
807+
effect_;
808808
predicate = predicate_;
809809
tparams;
810810
return;
@@ -824,7 +824,7 @@ with type t = Impl.t = struct
824824
~inner:(format_internal_comments params_comments)
825825
in
826826
let (node_name, nonhook_attrs) =
827-
if effect = Function.Hook then
827+
if effect_ = Function.Hook then
828828
("HookDeclaration", [])
829829
else
830830
( "FunctionDeclaration",
@@ -859,7 +859,7 @@ with type t = Impl.t = struct
859859
params = (_, { Function.Params.comments = params_comments; _ }) as params;
860860
async;
861861
generator;
862-
effect = _;
862+
effect_ = _;
863863
predicate = predicate_;
864864
tparams;
865865
return;
@@ -954,7 +954,7 @@ with type t = Impl.t = struct
954954
let id_loc = Loc.btwn (fst id) (fst annot) in
955955
let (name, predicate) =
956956
match annot with
957-
| (_, (_, Type.Function { Type.Function.effect = Function.Hook; _ })) -> ("DeclareHook", [])
957+
| (_, (_, Type.Function { Type.Function.effect_ = Function.Hook; _ })) -> ("DeclareHook", [])
958958
| _ -> ("DeclareFunction", [("predicate", option predicate predicate_)])
959959
in
960960
node
@@ -1807,7 +1807,7 @@ with type t = Impl.t = struct
18071807
(_, { Type.Function.Params.this_; params; rest; comments = params_comments });
18081808
return;
18091809
tparams;
1810-
effect;
1810+
effect_;
18111811
comments = func_comments;
18121812
}
18131813
) =
@@ -1817,7 +1817,7 @@ with type t = Impl.t = struct
18171817
~outer:func_comments
18181818
in
18191819
let name =
1820-
if effect = Function.Hook then
1820+
if effect_ = Function.Hook then
18211821
"HookTypeAnnotation"
18221822
else
18231823
"FunctionTypeAnnotation"
@@ -1833,7 +1833,7 @@ with type t = Impl.t = struct
18331833
("typeParameters", option type_parameter_declaration tparams);
18341834
]
18351835
@
1836-
if effect = Function.Hook then
1836+
if effect_ = Function.Hook then
18371837
[]
18381838
else
18391839
[("this", option function_type_this_constraint this_)]

src/parser/expression_parser.ml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1188,7 +1188,7 @@ module Expression
11881188
params;
11891189
body;
11901190
generator;
1191-
effect = Function.Arbitrary;
1191+
effect_ = Function.Arbitrary;
11921192
async;
11931193
predicate;
11941194
return;
@@ -1875,7 +1875,7 @@ module Expression
18751875
async;
18761876
generator = false;
18771877
(* arrow functions cannot be generators *)
1878-
effect = Function.Arbitrary;
1878+
effect_ = Function.Arbitrary;
18791879
predicate;
18801880
return;
18811881
tparams;

src/parser/flow_ast.ml

+3-3
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ and Type : sig
211211
params: ('M, 'T) Params.t;
212212
return: ('M, 'T) return_annotation;
213213
comments: ('M, unit) Syntax.t option;
214-
effect: Function.effect;
214+
effect_: Function.effect_;
215215
}
216216

217217
and ('M, 'T) return_annotation =
@@ -2377,7 +2377,7 @@ and Function : sig
23772377
[@@deriving show]
23782378
end
23792379

2380-
type effect =
2380+
type effect_ =
23812381
| Hook
23822382
| Arbitrary
23832383
| Idempotent
@@ -2390,7 +2390,7 @@ and Function : sig
23902390
body: ('M, 'T) body;
23912391
async: bool;
23922392
generator: bool;
2393-
effect: effect;
2393+
effect_: effect_;
23942394
predicate: ('M, 'T) Type.Predicate.t option;
23952395
return: ('M, 'T) ReturnAnnot.t;
23962396
tparams: ('M, 'T) Type.TypeParams.t option;

src/parser/flow_ast_mapper.ml

+4-4
Original file line numberDiff line numberDiff line change
@@ -1357,7 +1357,7 @@ class ['loc] mapper =
13571357
return;
13581358
tparams;
13591359
comments = func_comments;
1360-
effect;
1360+
effect_;
13611361
} =
13621362
ft
13631363
in
@@ -1387,7 +1387,7 @@ class ['loc] mapper =
13871387
return = return';
13881388
tparams = tparams';
13891389
comments = func_comments';
1390-
effect;
1390+
effect_;
13911391
}
13921392

13931393
method label_identifier (ident : ('loc, 'loc) Ast.Identifier.t) = this#identifier ident
@@ -1982,7 +1982,7 @@ class ['loc] mapper =
19821982
body;
19831983
async;
19841984
generator;
1985-
effect;
1985+
effect_;
19861986
predicate;
19871987
return;
19881988
tparams;
@@ -2016,7 +2016,7 @@ class ['loc] mapper =
20162016
body = body';
20172017
async;
20182018
generator;
2019-
effect;
2019+
effect_;
20202020
predicate = predicate';
20212021
tparams = tparams';
20222022
sig_loc;

src/parser/object_parser.ml

+3-3
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ module Object
179179
body;
180180
generator;
181181
async;
182-
effect = Function.Arbitrary;
182+
effect_ = Function.Arbitrary;
183183
predicate = None;
184184
(* setters/getter are not predicates *)
185185
return;
@@ -274,7 +274,7 @@ module Object
274274
params;
275275
body;
276276
generator;
277-
effect = Function.Arbitrary;
277+
effect_ = Function.Arbitrary;
278278
async;
279279
(* TODO: add support for object method predicates *)
280280
predicate = None;
@@ -850,7 +850,7 @@ module Object
850850
body;
851851
generator;
852852
async;
853-
effect = Function.Arbitrary;
853+
effect_ = Function.Arbitrary;
854854
(* TODO: add support for method predicates *)
855855
predicate = None;
856856
return;

src/parser/statement_parser.ml

+4-4
Original file line numberDiff line numberDiff line change
@@ -1211,7 +1211,7 @@ module Statement
12111211

12121212
and declare_function ~async ?(leading = []) env =
12131213
let leading = leading @ Peek.comments env in
1214-
let effect =
1214+
let effect_ =
12151215
match Peek.token env with
12161216
| T_FUNCTION ->
12171217
Eat.token env;
@@ -1232,18 +1232,18 @@ module Statement
12321232
Expect.token env T_COLON;
12331233
Eat.push_lex_mode env Lex_mode.TYPE;
12341234
let return =
1235-
if is_start_of_type_guard env && effect <> Function.Hook then
1235+
if is_start_of_type_guard env && effect_ <> Function.Hook then
12361236
Ast.Type.Function.TypeGuard (Type.type_guard env)
12371237
else
12381238
let return = Type._type env in
12391239
let has_predicate = Peek.token env = T_CHECKS in
1240-
if has_predicate && effect <> Function.Hook then
1240+
if has_predicate && effect_ <> Function.Hook then
12411241
Ast.Type.Function.TypeAnnotation (type_remove_trailing env return)
12421242
else
12431243
Ast.Type.Function.TypeAnnotation return
12441244
in
12451245
Eat.pop_lex_mode env;
1246-
Ast.Type.(Function { Function.params; return; tparams; comments = None; effect }))
1246+
Ast.Type.(Function { Function.params; return; tparams; comments = None; effect_ }))
12471247
env
12481248
in
12491249
let predicate = Type.predicate_opt env in

0 commit comments

Comments
 (0)