2 * Copyright (c) 2015, Facebook, Inc.
5 * This source code is licensed under the MIT license found in the
6 * LICENSE file in the "hack" directory of this source tree.
11 tco_safe_array
: bool;
12 tco_safe_vector_array
: bool;
13 tco_experimental_features
: SSet.t
;
14 tco_migration_flags
: SSet.t
;
15 tco_dynamic_view
: bool;
16 tco_disallow_array_as_tuple
: bool;
17 po_auto_namespace_map
: (string * string) list
;
19 po_deregister_php_stdlib
: bool;
20 po_disallow_execution_operator
: bool;
21 po_disable_nontoplevel_declarations
: bool;
22 po_disable_static_closures
: bool;
24 tco_log_inference_constraints
: bool;
25 tco_disallow_ambiguous_lambda
: bool;
26 tco_disallow_array_typehint
: bool;
27 tco_disallow_array_literal
: bool;
28 tco_language_feature_logging
: bool;
30 tco_disallow_implicit_returns_in_non_void_functions
: bool;
31 tco_disallow_unset_on_varray
: bool;
32 tco_disallow_scrutinee_case_value_type_mismatch
: bool;
33 tco_disallow_stringish_magic
: bool;
34 tco_new_inference_lambda
: bool;
36 tco_disallow_invalid_arraykey
: bool;
37 tco_disable_instanceof_refinement
: bool;
38 tco_disallow_byref_dynamic_calls
: bool;
39 po_disable_instanceof
: bool;
40 ignored_fixme_codes
: ISet.t
;
41 ignored_fixme_regex
: string option;
42 log_levels
: int SMap.t
;
43 po_disable_lval_as_an_expression
: bool;
44 tco_typecheck_xhp_cvars
: bool;
45 tco_ignore_collection_expr_type_arguments
: bool;
46 tco_shallow_class_decl
: bool;
48 tco_like_types
: bool;
49 tco_pessimize_types
: bool;
50 tco_coercion_from_dynamic
: bool;
51 tco_disable_partially_abstract_typeconsts
: bool;
52 error_codes_treated_strictly
: ISet.t
;
53 tco_check_xhp_attribute
: bool;
54 tco_disallow_unresolved_type_variables
: bool;
55 tco_disallow_invalid_arraykey_constraint
: bool;
58 let tco_experimental_instanceof = "instanceof"
60 let tco_experimental_isarray = "is_array"
62 let tco_experimental_goto = "goto"
65 * Prevents arraus from being promoted to shape-like or tuple-like arrays.
67 let tco_experimental_disable_shape_and_tuple_arrays =
68 "disable_shape_and_tuple_arrays"
70 (* Whether Shapes::idx should return a non-nullable type when the input shape
71 is known to contain the field. *)
72 let tco_experimental_stronger_shape_idx_ret =
73 "stronger_shape_idx_return"
75 (* Whether subtype assertions of form Tunion[] <: t should be added to
76 * todo list and checked later (usually generated from contravariant types) *)
77 let tco_experimental_unresolved_fix =
81 * Allows parsing type hints for function calls, such as foo<int>(args);.
83 let tco_experimental_annotate_function_calls =
84 "annotate_function_calls"
87 * Insist on instantiations for all generic types, even in non-strict files
89 let tco_experimental_generics_arity =
93 * Forbid casting nullable values, since they have unexpected semantics. For
94 * example, casting `null` to an int results in `0`, which may or may not be
95 * what you were expecting.
97 let tco_experimental_forbid_nullable_cast = "forbid_nullable_cast"
100 * Disallow static memoized functions in non-final classes
103 let tco_experimental_disallow_static_memoized = "disallow_static_memoized"
105 * Allows parsing of coroutine functions/suspend operator
107 let tco_experimental_coroutines =
111 * Enforce no duplication of traits in a class hierarchy. There is some clean-up
112 * involved, so it's behind a flag.
114 let tco_experimental_no_trait_reuse = "no_trait_reuse"
117 * Enable reified generics
119 let tco_experimental_reified_generics = "reified_generics"
122 * Prevent type param names from shadowing class names
124 let tco_experimental_type_param_shadowing = "type_param_shadowing"
127 * Enable trait method redeclarations, i.e. public function f(): void = T1::f;
129 let tco_experimental_trait_method_redeclarations = "trait_method_redeclarations"
132 * Enable attributes on type constants
134 let tco_experimental_type_const_attributes = "type_const_attributes"
137 * Enable declaration linearization
139 let tco_experimental_decl_linearization = "decl_linearization"
142 * Enable keeping track of the current subtype proposition in the environment.
144 let tco_experimental_track_subtype_prop = "track_subtype_prop"
147 * Enable support for the Pocket Universes
149 let tco_experimental_pocket_universes = "pocket_universes"
152 * Enable abstract const type with default syntax, i.e.
153 * abstract const type T as num = int;
155 let tco_experimental_abstract_type_const_with_default = "abstract_type_const_with_default"
157 let tco_experimental_all =
158 SSet.empty
|> List.fold_right
SSet.add
160 tco_experimental_instanceof;
161 tco_experimental_isarray;
162 tco_experimental_goto;
163 tco_experimental_disable_shape_and_tuple_arrays;
164 tco_experimental_stronger_shape_idx_ret;
165 tco_experimental_annotate_function_calls;
166 tco_experimental_unresolved_fix;
167 tco_experimental_generics_arity;
168 tco_experimental_forbid_nullable_cast;
169 tco_experimental_coroutines;
170 tco_experimental_disallow_static_memoized;
171 tco_experimental_no_trait_reuse;
172 tco_experimental_reified_generics;
173 tco_experimental_trait_method_redeclarations;
174 tco_experimental_type_const_attributes;
175 tco_experimental_decl_linearization;
176 tco_experimental_track_subtype_prop;
177 tco_experimental_abstract_type_const_with_default;
180 let tco_migration_flags_all =
181 SSet.empty
|> List.fold_right
SSet.add
187 tco_safe_array
= true;
188 tco_safe_vector_array
= true;
189 (** Default all features for testing. Actual options are set by reading
190 * from hhconfig, which defaults to empty. *)
191 tco_experimental_features
= tco_experimental_all;
192 tco_migration_flags
= SSet.empty
;
193 tco_dynamic_view
= false;
194 tco_disallow_array_as_tuple
= false;
195 po_auto_namespace_map
= [];
197 po_disallow_execution_operator
= false;
198 po_deregister_php_stdlib
= false;
199 po_disable_nontoplevel_declarations
= false;
200 po_disable_static_closures
= false;
201 po_allow_goto
= true;
202 tco_log_inference_constraints
= false;
203 tco_disallow_ambiguous_lambda
= false;
204 tco_disallow_array_typehint
= false;
205 tco_disallow_array_literal
= false;
206 tco_language_feature_logging
= false;
207 tco_unsafe_rx
= true;
208 tco_disallow_implicit_returns_in_non_void_functions
= true;
209 tco_disallow_unset_on_varray
= false;
210 tco_disallow_scrutinee_case_value_type_mismatch
= false;
211 tco_disallow_stringish_magic
= false;
212 tco_new_inference_lambda
= false;
214 tco_disallow_invalid_arraykey
= false;
215 tco_disable_instanceof_refinement
= false;
216 tco_disallow_byref_dynamic_calls
= false;
217 po_disable_instanceof
= false;
218 ignored_fixme_codes
= Errors.default_ignored_fixme_codes
;
219 ignored_fixme_regex
= None
;
220 log_levels
= SMap.empty
;
221 po_disable_lval_as_an_expression
= false;
222 tco_typecheck_xhp_cvars
= false;
223 tco_ignore_collection_expr_type_arguments
= false;
224 tco_shallow_class_decl
= false;
226 tco_like_types
= false;
227 tco_pessimize_types
= false;
228 tco_coercion_from_dynamic
= false;
229 tco_disable_partially_abstract_typeconsts
= false;
230 error_codes_treated_strictly
= ISet.of_list
[];
231 tco_check_xhp_attribute
= false;
232 tco_disallow_unresolved_type_variables
= false;
233 tco_disallow_invalid_arraykey_constraint
= false;
237 ?
(tco_safe_array
= default.tco_safe_array
)
238 ?
(tco_safe_vector_array
= default.tco_safe_vector_array
)
239 ?
(po_deregister_php_stdlib
= default.po_deregister_php_stdlib
)
240 ?
(po_disallow_execution_operator
= default.po_disallow_execution_operator
)
241 ?
(po_disable_nontoplevel_declarations
= default.po_disable_nontoplevel_declarations
)
242 ?
(po_disable_static_closures
= default.po_disable_static_closures
)
243 ?
(po_allow_goto
= default.po_allow_goto
)
244 ?
(tco_log_inference_constraints
= default.tco_log_inference_constraints
)
245 ?
(tco_experimental_features
= default.tco_experimental_features
)
246 ?
(tco_migration_flags
= default.tco_migration_flags
)
247 ?
(tco_dynamic_view
= default.tco_dynamic_view
)
248 ?
(tco_disallow_array_as_tuple
= default.tco_disallow_array_as_tuple
)
249 ?
(po_auto_namespace_map
= default.po_auto_namespace_map
)
250 ?
(tco_disallow_ambiguous_lambda
= default.tco_disallow_ambiguous_lambda
)
251 ?
(tco_disallow_array_typehint
= default.tco_disallow_array_typehint
)
252 ?
(tco_disallow_array_literal
= default.tco_disallow_array_literal
)
253 ?
(tco_language_feature_logging
= default.tco_language_feature_logging
)
254 ?
(tco_unsafe_rx
= default.tco_unsafe_rx
)
255 ?
(tco_disallow_implicit_returns_in_non_void_functions
= default.tco_disallow_implicit_returns_in_non_void_functions
)
256 ?
(tco_disallow_unset_on_varray
= default.tco_disallow_unset_on_varray
)
257 ?
(tco_disallow_scrutinee_case_value_type_mismatch
= default.tco_disallow_scrutinee_case_value_type_mismatch
)
258 ?
(tco_disallow_stringish_magic
= default.tco_disallow_stringish_magic
)
259 ?
(tco_new_inference_lambda
= default.tco_new_inference_lambda
)
260 ?
(tco_timeout
= default.tco_timeout
)
261 ?
(tco_disallow_invalid_arraykey
= default.tco_disallow_invalid_arraykey
)
262 ?
(tco_disable_instanceof_refinement
= default.tco_disable_instanceof_refinement
)
263 ?
(tco_disallow_byref_dynamic_calls
= default.tco_disallow_byref_dynamic_calls
)
264 ?
(po_disable_instanceof
= default.po_disable_instanceof
)
265 ?
(ignored_fixme_codes
= default.ignored_fixme_codes
)
267 ?
(log_levels
= default.log_levels
)
268 ?
(po_disable_lval_as_an_expression
= default.po_disable_lval_as_an_expression
)
269 ?
(tco_typecheck_xhp_cvars
= default.tco_typecheck_xhp_cvars
)
270 ?
(tco_ignore_collection_expr_type_arguments
= default.tco_ignore_collection_expr_type_arguments
)
271 ?
(tco_shallow_class_decl
= default.tco_shallow_class_decl
)
272 ?
(po_rust
= default.po_rust
)
273 ?
(tco_like_types
= default.tco_like_types
)
274 ?
(tco_pessimize_types
= default.tco_pessimize_types
)
275 ?
(tco_coercion_from_dynamic
= default.tco_coercion_from_dynamic
)
276 ?
(tco_disable_partially_abstract_typeconsts
= default.tco_disable_partially_abstract_typeconsts
)
277 ?
(error_codes_treated_strictly
= default.error_codes_treated_strictly
)
278 ?
(tco_check_xhp_attribute
= default.tco_check_xhp_attribute
)
279 ?
(tco_disallow_unresolved_type_variables
= default.tco_disallow_unresolved_type_variables
)
280 ?
(tco_disallow_invalid_arraykey_constraint
= default.tco_disallow_invalid_arraykey_constraint
)
284 tco_safe_vector_array
;
285 tco_experimental_features
;
288 tco_disallow_array_as_tuple
;
289 po_auto_namespace_map
;
293 po_deregister_php_stdlib
;
294 po_disallow_execution_operator
;
295 po_disable_nontoplevel_declarations
;
296 po_disable_static_closures
;
298 tco_log_inference_constraints
;
299 tco_disallow_ambiguous_lambda
;
300 tco_disallow_array_typehint
;
301 tco_disallow_array_literal
;
302 tco_language_feature_logging
;
304 tco_disallow_implicit_returns_in_non_void_functions
;
305 tco_disallow_unset_on_varray
;
306 tco_disallow_scrutinee_case_value_type_mismatch
;
307 tco_disallow_stringish_magic
;
308 tco_new_inference_lambda
;
310 tco_disallow_invalid_arraykey
;
311 tco_disable_instanceof_refinement
;
312 tco_disallow_byref_dynamic_calls
;
313 po_disable_instanceof
;
315 po_disable_lval_as_an_expression
;
316 tco_typecheck_xhp_cvars
;
317 tco_ignore_collection_expr_type_arguments
;
318 tco_shallow_class_decl
;
322 tco_coercion_from_dynamic
;
323 tco_disable_partially_abstract_typeconsts
;
324 error_codes_treated_strictly
;
325 tco_check_xhp_attribute
;
326 tco_disallow_unresolved_type_variables
;
327 tco_disallow_invalid_arraykey_constraint
;
329 let tco_safe_array t
= t
.tco_safe_array
330 let tco_safe_vector_array t
= t
.tco_safe_vector_array
331 let tco_experimental_feature_enabled t s
=
332 SSet.mem s t
.tco_experimental_features
333 let tco_migration_flag_enabled t s
=
334 SSet.mem s t
.tco_migration_flags
335 let tco_dynamic_view t
=
337 let tco_disallow_array_as_tuple t
=
338 t
.tco_disallow_array_as_tuple
339 let po_auto_namespace_map t
= t
.po_auto_namespace_map
340 let po_deregister_php_stdlib t
= t
.po_deregister_php_stdlib
341 let po_disable_nontoplevel_declarations t
= t
.po_disable_nontoplevel_declarations
342 let po_disable_static_closures t
= t
.po_disable_static_closures
343 let po_allow_goto t
= t
.po_allow_goto
344 let tco_log_inference_constraints t
= t
.tco_log_inference_constraints
345 let po_codegen t
= t
.po_codegen
346 let po_disallow_execution_operator t
= t
.po_disallow_execution_operator
347 let tco_disallow_ambiguous_lambda t
= t
.tco_disallow_ambiguous_lambda
348 let tco_disallow_array_typehint t
= t
.tco_disallow_array_typehint
349 let tco_disallow_array_literal t
= t
.tco_disallow_array_literal
350 let tco_language_feature_logging t
= t
.tco_language_feature_logging
351 let tco_unsafe_rx t
= t
.tco_unsafe_rx
352 let tco_disallow_implicit_returns_in_non_void_functions t
=
353 t
.tco_disallow_implicit_returns_in_non_void_functions
354 let tco_disallow_unset_on_varray t
= t
.tco_disallow_unset_on_varray
355 let tco_disallow_scrutinee_case_value_type_mismatch t
=
356 t
.tco_disallow_scrutinee_case_value_type_mismatch
357 let tco_disallow_stringish_magic t
= t
.tco_disallow_stringish_magic
358 let tco_new_inference_lambda t
= t
.tco_new_inference_lambda
359 let tco_timeout t
= t
.tco_timeout
360 let tco_disallow_invalid_arraykey t
= t
.tco_disallow_invalid_arraykey
361 let tco_disallow_invalid_arraykey_constraint t
= t
.tco_disallow_invalid_arraykey_constraint
362 let tco_disable_instanceof_refinement t
= t
.tco_disable_instanceof_refinement
363 let tco_disallow_byref_dynamic_calls t
= t
.tco_disallow_byref_dynamic_calls
364 let po_disable_instanceof t
= t
.po_disable_instanceof
365 let ignored_fixme_codes t
= t
.ignored_fixme_codes
366 let ignored_fixme_regex t
= t
.ignored_fixme_regex
367 let log_levels t
= t
.log_levels
368 let po_disable_lval_as_an_expression t
= t
.po_disable_lval_as_an_expression
369 let tco_typecheck_xhp_cvars t
= t
.tco_typecheck_xhp_cvars
370 let tco_shallow_class_decl t
= t
.tco_shallow_class_decl
371 let po_rust t
= t
.po_rust
372 let tco_like_types t
= t
.tco_like_types
373 let tco_pessimize_types t
= t
.tco_pessimize_types
374 let tco_coercion_from_dynamic t
= t
.tco_coercion_from_dynamic
375 let tco_disable_partially_abstract_typeconsts t
= t
.tco_disable_partially_abstract_typeconsts
376 let error_codes_treated_strictly t
= t
.error_codes_treated_strictly
378 let tco_ignore_collection_expr_type_arguments t
= t
.tco_ignore_collection_expr_type_arguments
380 let tco_check_xhp_attribute t
= t
.tco_check_xhp_attribute
382 let tco_disallow_unresolved_type_variables t
= t
.tco_disallow_unresolved_type_variables
384 let setup_pocket_universes env enabled
=
385 let exp_features = env
.tco_experimental_features
in
386 let exp_features = if enabled
then
387 SSet.add
tco_experimental_pocket_universes exp_features
389 SSet.remove
tco_experimental_pocket_universes exp_features
390 in { env
with tco_experimental_features
= exp_features }