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
;
18 po_enable_hh_syntax_for_hhvm
: bool;
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 po_enable_concurrent
: bool;
25 po_enable_await_as_an_expression
: bool;
26 tco_log_inference_constraints
: bool;
27 tco_disallow_ambiguous_lambda
: bool;
28 tco_disallow_array_typehint
: bool;
29 tco_disallow_array_literal
: bool;
30 tco_language_feature_logging
: bool;
32 tco_disallow_implicit_returns_in_non_void_functions
: bool;
33 tco_disallow_unset_on_varray
: bool;
34 tco_disallow_scrutinee_case_value_type_mismatch
: bool;
35 tco_disallow_stringish_magic
: bool;
36 tco_new_inference
: float;
37 tco_new_inference_lambda
: bool;
39 tco_disallow_invalid_arraykey
: bool;
40 tco_disable_instanceof_refinement
: bool;
41 tco_disallow_ref_param_on_constructor
: bool;
42 tco_disallow_byref_dynamic_calls
: bool;
43 po_disable_instanceof
: bool;
44 ignored_fixme_codes
: ISet.t
;
45 ignored_fixme_regex
: string option;
46 log_levels
: int SMap.t
;
47 po_enable_stronger_await_binding
: bool;
48 po_disable_lval_as_an_expression
: bool;
49 po_disable_unsafe_expr
: bool;
50 po_disable_unsafe_block
: bool;
51 tco_typecheck_xhp_cvars
: bool;
52 tco_ignore_collection_expr_type_arguments
: bool;
53 tco_disallow_byref_prop_args
: bool;
54 tco_shallow_class_decl
: bool;
56 tco_like_types
: bool;
59 let tco_experimental_instanceof = "instanceof"
61 let tco_experimental_isarray = "is_array"
63 let tco_experimental_goto = "goto"
66 * Prevents arraus from being promoted to shape-like or tuple-like arrays.
68 let tco_experimental_disable_shape_and_tuple_arrays =
69 "disable_shape_and_tuple_arrays"
71 (* Whether Shapes::idx should return a non-nullable type when the input shape
72 is known to contain the field. *)
73 let tco_experimental_stronger_shape_idx_ret =
74 "stronger_shape_idx_return"
76 (* Whether subtype assertions of form Tunion[] <: t should be added to
77 * todo list and checked later (usually generated from contravariant types) *)
78 let tco_experimental_unresolved_fix =
82 * Allows parsing type hints for function calls, such as foo<int>(args);.
84 let tco_experimental_annotate_function_calls =
85 "annotate_function_calls"
88 * Insist on instantiations for all generic types, even in non-strict files
90 let tco_experimental_generics_arity =
94 * Forbid casting nullable values, since they have unexpected semantics. For
95 * example, casting `null` to an int results in `0`, which may or may not be
96 * what you were expecting.
98 let tco_experimental_forbid_nullable_cast = "forbid_nullable_cast"
101 * Disallow static memoized functions in non-final classes
104 let tco_experimental_disallow_static_memoized = "disallow_static_memoized"
106 * Allows parsing of coroutine functions/suspend operator
108 let tco_experimental_coroutines =
112 * Enforce no duplication of traits in a class hierarchy. There is some clean-up
113 * involved, so it's behind a flag.
115 let tco_experimental_no_trait_reuse = "no_trait_reuse"
118 * Enable reified generics
120 let tco_experimental_reified_generics = "reified_generics"
123 * Prevent type param names from shadowing class names
125 let tco_experimental_type_param_shadowing = "type_param_shadowing"
128 * Enable trait method redeclarations, i.e. public function f(): void = T1::f;
130 let tco_experimental_trait_method_redeclarations = "trait_method_redeclarations"
133 * Enable attributes on type constants
135 let tco_experimental_type_const_attributes = "type_const_attributes"
138 * Enable declaration linearization
140 let tco_experimental_decl_linearization = "decl_linearization"
143 * Enable keeping track of the current subtype proposition in the environment.
145 let tco_experimental_track_subtype_prop = "track_subtype_prop"
148 * Enable support for the Pocket Universes
150 let tco_experimental_pocket_universes = "pocket_universes"
153 * Enable abstract const type with default syntax, i.e.
154 * abstract const type T as num = int;
156 let tco_experimental_abstract_type_const_with_default = "abstract_type_const_with_default"
158 let tco_experimental_all =
159 SSet.empty
|> List.fold_right
SSet.add
161 tco_experimental_instanceof;
162 tco_experimental_isarray;
163 tco_experimental_goto;
164 tco_experimental_disable_shape_and_tuple_arrays;
165 tco_experimental_stronger_shape_idx_ret;
166 tco_experimental_annotate_function_calls;
167 tco_experimental_unresolved_fix;
168 tco_experimental_generics_arity;
169 tco_experimental_forbid_nullable_cast;
170 tco_experimental_coroutines;
171 tco_experimental_disallow_static_memoized;
172 tco_experimental_no_trait_reuse;
173 tco_experimental_reified_generics;
174 tco_experimental_type_param_shadowing;
175 tco_experimental_trait_method_redeclarations;
176 tco_experimental_type_const_attributes;
177 tco_experimental_decl_linearization;
178 tco_experimental_track_subtype_prop;
179 tco_experimental_abstract_type_const_with_default;
182 let tco_migration_flags_all =
183 SSet.empty
|> List.fold_right
SSet.add
189 tco_safe_array
= true;
190 tco_safe_vector_array
= true;
191 (** Default all features for testing. Actual options are set by reading
192 * from hhconfig, which defaults to empty. *)
193 tco_experimental_features
= tco_experimental_all;
194 tco_migration_flags
= SSet.empty
;
195 tco_dynamic_view
= false;
196 tco_disallow_array_as_tuple
= false;
197 po_auto_namespace_map
= [];
198 po_enable_hh_syntax_for_hhvm
= false;
199 po_disallow_execution_operator
= false;
200 po_deregister_php_stdlib
= false;
201 po_disable_nontoplevel_declarations
= false;
202 po_disable_static_closures
= false;
203 po_allow_goto
= true;
204 po_enable_concurrent
= false;
205 po_enable_await_as_an_expression
= false;
206 tco_log_inference_constraints
= false;
207 tco_disallow_ambiguous_lambda
= false;
208 tco_disallow_array_typehint
= false;
209 tco_disallow_array_literal
= false;
210 tco_language_feature_logging
= false;
211 tco_unsafe_rx
= true;
212 tco_disallow_implicit_returns_in_non_void_functions
= true;
213 tco_disallow_unset_on_varray
= false;
214 tco_disallow_scrutinee_case_value_type_mismatch
= false;
215 tco_disallow_stringish_magic
= false;
216 tco_new_inference
= 0.0;
217 tco_new_inference_lambda
= false;
219 tco_disallow_invalid_arraykey
= false;
220 tco_disable_instanceof_refinement
= false;
221 tco_disallow_ref_param_on_constructor
= false;
222 tco_disallow_byref_dynamic_calls
= false;
223 po_disable_instanceof
= false;
224 ignored_fixme_codes
= Errors.default_ignored_fixme_codes
;
225 ignored_fixme_regex
= None
;
226 log_levels
= SMap.empty
;
227 po_enable_stronger_await_binding
= false;
228 po_disable_lval_as_an_expression
= false;
229 po_disable_unsafe_expr
= false;
230 po_disable_unsafe_block
= false;
231 tco_typecheck_xhp_cvars
= false;
232 tco_ignore_collection_expr_type_arguments
= false;
233 tco_disallow_byref_prop_args
= false;
234 tco_shallow_class_decl
= false;
236 tco_like_types
= false;
240 ?
(tco_safe_array
= default.tco_safe_array
)
241 ?
(tco_safe_vector_array
= default.tco_safe_vector_array
)
242 ?
(po_deregister_php_stdlib
= default.po_deregister_php_stdlib
)
243 ?
(po_disallow_execution_operator
= default.po_disallow_execution_operator
)
244 ?
(po_disable_nontoplevel_declarations
= default.po_disable_nontoplevel_declarations
)
245 ?
(po_disable_static_closures
= default.po_disable_static_closures
)
246 ?
(po_allow_goto
= default.po_allow_goto
)
247 ?
(po_enable_concurrent
= default.po_enable_concurrent
)
248 ?
(po_enable_await_as_an_expression
= default.po_enable_await_as_an_expression
)
249 ?
(tco_log_inference_constraints
= default.tco_log_inference_constraints
)
250 ?
(tco_experimental_features
= default.tco_experimental_features
)
251 ?
(tco_migration_flags
= default.tco_migration_flags
)
252 ?
(tco_dynamic_view
= default.tco_dynamic_view
)
253 ?
(tco_disallow_array_as_tuple
= default.tco_disallow_array_as_tuple
)
254 ?
(po_auto_namespace_map
= default.po_auto_namespace_map
)
255 ?
(tco_disallow_ambiguous_lambda
= default.tco_disallow_ambiguous_lambda
)
256 ?
(tco_disallow_array_typehint
= default.tco_disallow_array_typehint
)
257 ?
(tco_disallow_array_literal
= default.tco_disallow_array_literal
)
258 ?
(tco_language_feature_logging
= default.tco_language_feature_logging
)
259 ?
(tco_unsafe_rx
= default.tco_unsafe_rx
)
260 ?
(tco_disallow_implicit_returns_in_non_void_functions
= default.tco_disallow_implicit_returns_in_non_void_functions
)
261 ?
(tco_disallow_unset_on_varray
= default.tco_disallow_unset_on_varray
)
262 ?
(tco_disallow_scrutinee_case_value_type_mismatch
= default.tco_disallow_scrutinee_case_value_type_mismatch
)
263 ?
(tco_disallow_stringish_magic
= default.tco_disallow_stringish_magic
)
264 ?
(tco_new_inference
= default.tco_new_inference
)
265 ?
(tco_new_inference_lambda
= default.tco_new_inference_lambda
)
266 ?
(tco_timeout
= default.tco_timeout
)
267 ?
(tco_disallow_invalid_arraykey
= default.tco_disallow_invalid_arraykey
)
268 ?
(tco_disable_instanceof_refinement
= default.tco_disable_instanceof_refinement
)
269 ?
(tco_disallow_ref_param_on_constructor
= default.tco_disallow_ref_param_on_constructor
)
270 ?
(tco_disallow_byref_dynamic_calls
= default.tco_disallow_byref_dynamic_calls
)
271 ?
(po_disable_instanceof
= default.po_disable_instanceof
)
272 ?
(ignored_fixme_codes
= default.ignored_fixme_codes
)
274 ?
(log_levels
= default.log_levels
)
275 ?
(po_enable_stronger_await_binding
= default.po_enable_stronger_await_binding
)
276 ?
(po_disable_lval_as_an_expression
= default.po_disable_lval_as_an_expression
)
277 ?
(po_disable_unsafe_expr
= default.po_disable_unsafe_expr
)
278 ?
(po_disable_unsafe_block
= default.po_disable_unsafe_block
)
279 ?
(tco_typecheck_xhp_cvars
= default.tco_typecheck_xhp_cvars
)
280 ?
(tco_ignore_collection_expr_type_arguments
= default.tco_ignore_collection_expr_type_arguments
)
281 ?
(tco_disallow_byref_prop_args
= default.tco_disallow_byref_prop_args
)
282 ?
(tco_shallow_class_decl
= default.tco_shallow_class_decl
)
283 ?
(po_rust
= default.po_rust
)
284 ?
(tco_like_types
= default.tco_like_types
)
288 tco_safe_vector_array
;
289 tco_experimental_features
;
292 tco_disallow_array_as_tuple
;
293 po_auto_namespace_map
;
294 po_enable_hh_syntax_for_hhvm
= false;
297 po_deregister_php_stdlib
;
298 po_disallow_execution_operator
;
299 po_disable_nontoplevel_declarations
;
300 po_disable_static_closures
;
302 po_enable_concurrent
;
303 po_enable_await_as_an_expression
;
304 tco_log_inference_constraints
;
305 tco_disallow_ambiguous_lambda
;
306 tco_disallow_array_typehint
;
307 tco_disallow_array_literal
;
308 tco_language_feature_logging
;
310 tco_disallow_implicit_returns_in_non_void_functions
;
311 tco_disallow_unset_on_varray
;
312 tco_disallow_scrutinee_case_value_type_mismatch
;
313 tco_disallow_stringish_magic
;
315 tco_new_inference_lambda
;
317 tco_disallow_invalid_arraykey
;
318 tco_disable_instanceof_refinement
;
319 tco_disallow_ref_param_on_constructor
;
320 tco_disallow_byref_dynamic_calls
;
321 po_disable_instanceof
;
323 po_enable_stronger_await_binding
;
324 po_disable_lval_as_an_expression
;
325 po_disable_unsafe_expr
;
326 po_disable_unsafe_block
;
327 tco_typecheck_xhp_cvars
;
328 tco_ignore_collection_expr_type_arguments
;
329 tco_disallow_byref_prop_args
;
330 tco_shallow_class_decl
;
334 let tco_safe_array t
= t
.tco_safe_array
335 let tco_safe_vector_array t
= t
.tco_safe_vector_array
336 let tco_experimental_feature_enabled t s
=
337 SSet.mem s t
.tco_experimental_features
338 let tco_migration_flag_enabled t s
=
339 SSet.mem s t
.tco_migration_flags
340 let tco_dynamic_view t
=
342 let tco_disallow_array_as_tuple t
=
343 t
.tco_disallow_array_as_tuple
344 let po_auto_namespace_map t
= t
.po_auto_namespace_map
345 let po_deregister_php_stdlib t
= t
.po_deregister_php_stdlib
346 let po_disable_nontoplevel_declarations t
= t
.po_disable_nontoplevel_declarations
347 let po_disable_static_closures t
= t
.po_disable_static_closures
348 let po_allow_goto t
= t
.po_allow_goto
349 let po_enable_concurrent t
= t
.po_enable_concurrent
350 let po_enable_await_as_an_expression t
= t
.po_enable_await_as_an_expression
351 let tco_log_inference_constraints t
= t
.tco_log_inference_constraints
352 let po_enable_hh_syntax_for_hhvm t
= t
.po_enable_hh_syntax_for_hhvm
353 let po_disallow_execution_operator t
= t
.po_disallow_execution_operator
354 let tco_disallow_ambiguous_lambda t
= t
.tco_disallow_ambiguous_lambda
355 let tco_disallow_array_typehint t
= t
.tco_disallow_array_typehint
356 let tco_disallow_array_literal t
= t
.tco_disallow_array_literal
357 let tco_language_feature_logging t
= t
.tco_language_feature_logging
358 let tco_unsafe_rx t
= t
.tco_unsafe_rx
359 let tco_disallow_implicit_returns_in_non_void_functions t
=
360 t
.tco_disallow_implicit_returns_in_non_void_functions
361 let tco_disallow_unset_on_varray t
= t
.tco_disallow_unset_on_varray
362 let tco_disallow_scrutinee_case_value_type_mismatch t
=
363 t
.tco_disallow_scrutinee_case_value_type_mismatch
364 let tco_disallow_stringish_magic t
= t
.tco_disallow_stringish_magic
365 let tco_new_inference t
= t
.tco_new_inference > 0.0
366 let tco_new_inference_lambda t
= t
.tco_new_inference_lambda
367 let tco_timeout t
= t
.tco_timeout
368 let tco_disallow_invalid_arraykey t
= t
.tco_disallow_invalid_arraykey
369 let tco_disable_instanceof_refinement t
= t
.tco_disable_instanceof_refinement
370 let tco_disallow_ref_param_on_constructor t
= t
.tco_disallow_ref_param_on_constructor
371 let tco_disallow_byref_dynamic_calls t
= t
.tco_disallow_byref_dynamic_calls
372 let po_disable_instanceof t
= t
.po_disable_instanceof
373 let ignored_fixme_codes t
= t
.ignored_fixme_codes
374 let ignored_fixme_regex t
= t
.ignored_fixme_regex
375 let log_levels t
= t
.log_levels
376 let po_enable_stronger_await_binding t
= t
.po_enable_stronger_await_binding
377 let po_disable_lval_as_an_expression t
= t
.po_disable_lval_as_an_expression
378 let po_disable_unsafe_expr t
= t
.po_disable_unsafe_expr
379 let po_disable_unsafe_block t
= t
.po_disable_unsafe_block
380 let tco_typecheck_xhp_cvars t
= t
.tco_typecheck_xhp_cvars
381 let tco_disallow_byref_prop_args t
= t
.tco_disallow_byref_prop_args
382 let tco_shallow_class_decl t
= t
.tco_shallow_class_decl
383 let po_rust t
= t
.po_rust
384 let tco_like_types t
= t
.tco_like_types
386 let tco_ignore_collection_expr_type_arguments t
= t
.tco_ignore_collection_expr_type_arguments
387 let setup_pocket_universes env enabled
=
388 let exp_features = env
.tco_experimental_features
in
389 let exp_features = if enabled
then
390 SSet.add
tco_experimental_pocket_universes exp_features
392 SSet.remove
tco_experimental_pocket_universes exp_features
393 in { env
with tco_experimental_features
= exp_features }