Skip to content

Commit

Permalink
Back out "[flow] max size for normalizer"
Browse files Browse the repository at this point in the history
Summary:
Not necessary with the optimization in the previous diff.

Original commit changeset: b89373bbe330

Original Phabricator Diff: D59973531

Changelog: [internal]

Reviewed By: SamChou19815

Differential Revision: D65280484

fbshipit-source-id: 47d63a05ec76f08de4e2e2ed55476165eb175c58
  • Loading branch information
panagosg7 authored and facebook-github-bot committed Oct 31, 2024
1 parent 58a8951 commit 97ce0a2
Show file tree
Hide file tree
Showing 6 changed files with 2 additions and 46 deletions.
1 change: 0 additions & 1 deletion src/commands/glean/gleanRunner.ml
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,6 @@ let extract_member_def ~cx ~typed_ast ~file_sig scheme name : ALoc.t list =
match
Ty_members.extract
~cx
~max_size:2000
~allowed_prop_names:[Reason.OrdinaryName name]
~typed_ast_opt:(Some typed_ast)
~file_sig
Expand Down
2 changes: 0 additions & 2 deletions src/typing/query_types.ml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ let type_at_pos_type
merge_bot_and_any_kinds = true;
verbose_normalizer;
max_depth = Some max_depth;
max_size = None;
toplevel_is_type_identifier_reference;
}
in
Expand Down Expand Up @@ -145,7 +144,6 @@ let insert_type_normalize ~cx ~file_sig ~omit_targ_defaults ~typed_ast loc t : T
merge_bot_and_any_kinds = true;
verbose_normalizer = false;
max_depth = None;
max_size = None;
toplevel_is_type_identifier_reference = false;
}
in
Expand Down
4 changes: 1 addition & 3 deletions src/typing/ty_members.ml
Original file line number Diff line number Diff line change
Expand Up @@ -312,8 +312,7 @@ type ty_members = {
errors: string list;
}

let extract
?(force_instance = false) ?max_size ?allowed_prop_names ~cx ~typed_ast_opt ~file_sig scheme =
let extract ?(force_instance = false) ?allowed_prop_names ~cx ~typed_ast_opt ~file_sig scheme =
let options =
{
Ty_normalizer_env.expand_internal_types = true;
Expand All @@ -324,7 +323,6 @@ let extract
merge_bot_and_any_kinds = true;
verbose_normalizer = false;
max_depth = Some 40;
max_size;
toplevel_is_type_identifier_reference = false;
}
in
Expand Down
1 change: 0 additions & 1 deletion src/typing/ty_members.mli
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ type ty_members = {

val extract :
?force_instance:bool ->
?max_size:int ->
?allowed_prop_names:Reason.name list ->
cx:Context.t ->
typed_ast_opt:(ALoc.t, ALoc.t * Type.t) Flow_ast.Program.t option ->
Expand Down
36 changes: 1 addition & 35 deletions src/typing/ty_normalizer.ml
Original file line number Diff line number Diff line change
Expand Up @@ -185,15 +185,13 @@ module Make (I : INPUT) : S = struct
rec_tvar_ids: ISet.t;
rec_eval_ids: Type.EvalIdSet.t;
found_computed_type: bool;
size: int;
}

let empty =
{
rec_tvar_ids = ISet.empty;
rec_eval_ids = Type.EvalIdSet.empty;
found_computed_type = false;
size = 0;
}

let found_computed_type { found_computed_type = x; _ } = x
Expand Down Expand Up @@ -285,23 +283,6 @@ module Make (I : INPUT) : S = struct

let non_opt_param = Ty.{ prm_optional = false }

let mk_fun_t
?(params = [])
?(effect = Ty.Arbitrary)
?rest
?tparams
?(static = Ty.(TypeOf (FunProto, None)))
ret =
Ty.
{
fun_params = params;
fun_rest_param = rest;
fun_return = ret;
fun_type_params = tparams;
fun_static = static;
fun_effect = effect;
}

let mk_fun
?(params = [])
?(effect = Ty.Arbitrary)
Expand Down Expand Up @@ -663,19 +644,7 @@ module Make (I : INPUT) : S = struct
let%bind env = descend env t in

let depth = env.Env.depth - 1 in
let%bind stop =
match Env.(env.genv.options.max_size) with
| Some max_size ->
let%bind state = get in
let size = state.State.size in
let state = { state with State.size = size + 1 } in
let%map () = put state in
size > max_size
| None -> return false
in
if stop then
return (Ty.Any Ty.Recursive)
else if Env.verbose env then
if Env.verbose env then
type_debug ~env ?id ~depth t
else
type_with_alias_reason ~env ?id t
Expand Down Expand Up @@ -950,7 +919,6 @@ module Make (I : INPUT) : S = struct
let rec go = function
| Ty.Fun ft -> return [ft]
| Ty.Inter (t1, t2, ts) -> concat_fold_m go (t1 :: t2 :: ts)
| Ty.Any a -> return [mk_fun_t (Ty.ReturnType (Ty.Any a))]
| _ -> terr ~kind:BadMethodType (Some t)
in
let%bind ty = type__ ~env t in
Expand Down Expand Up @@ -2100,7 +2068,6 @@ module Make (I : INPUT) : S = struct
state
t : ('a, error) result * State.t =
let env = Env.init ~genv in
let state = { state with State.size = 0 } in
let (result, state) = run state (f ~env t) in
let result =
match result with
Expand Down Expand Up @@ -2169,7 +2136,6 @@ module Make (I : INPUT) : S = struct
let (_, result) =
List.fold_left
(fun (st, acc) (name, loc, import_mode, t) ->
let st = { st with State.size = 0 } in
match run st (convert genv t) with
| (Ok (Some def_loc), st) -> (st, ALocMap.add def_loc (loc, name, import_mode) acc)
| (Ok None, st) ->
Expand Down
4 changes: 0 additions & 4 deletions src/typing/ty_normalizer_env.ml
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@ type options = {
verbose_normalizer: bool;
(* Maximum depth of recursion *)
max_depth: int option;
(* Maximum size of type *)
max_size: int option;
(* In typed AST for type references, we store the type as if it's read under the
* value namespace. In some places, we might want to record the fact that it's
* a type-namespace read. *)
Expand All @@ -74,7 +72,6 @@ let default_options =
preserve_inferred_literal_types = false;
verbose_normalizer = false;
max_depth = Some 40;
max_size = None;
toplevel_is_type_identifier_reference = false;
}

Expand All @@ -88,7 +85,6 @@ let default_codemod_options =
merge_bot_and_any_kinds = false;
verbose_normalizer = false;
max_depth = None;
max_size = None;
toplevel_is_type_identifier_reference = false;
}

Expand Down

0 comments on commit 97ce0a2

Please sign in to comment.