Skip to content

Commit 97814ee

Browse files
MarisaKirisamefacebook-github-bot
authored andcommitted
Add new configuration option "tco_constraint_array_index"
Summary: Add new configuration option "tco_constraint_array_index", which will gate constraint based typechecking of array indexing expression Differential Revision: D77380458 fbshipit-source-id: ba1f3f7afa9bf23a37e79c3207b06ca80a776442
1 parent ca6dc74 commit 97814ee

File tree

7 files changed

+16
-1
lines changed

7 files changed

+16
-1
lines changed

hphp/hack/src/client_and_server/serverConfig.ml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,7 @@ let load_config (config : Config_file_common.t) (options : GlobalOptions.t) :
382382
?tco_language_feature_logging:(bool_opt "language_feature_logging" config)
383383
?tco_timeout:(int_opt "timeout" config)
384384
?tco_disallow_invalid_arraykey:(bool_opt "disallow_invalid_arraykey" config)
385+
?tco_constraint_array_index:(bool_opt "constraint_array_index" config)
385386
?code_agnostic_fixme:(bool_opt "code_agnostic_fixme" config)
386387
?allowed_fixme_codes_strict:
387388
(prepare_iset config "allowed_fixme_codes_strict")

hphp/hack/src/options/globalOptions.ml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ type t = {
103103
tco_language_feature_logging: bool;
104104
tco_timeout: int;
105105
tco_disallow_invalid_arraykey: bool;
106+
tco_constraint_array_index: bool;
106107
code_agnostic_fixme: bool;
107108
allowed_fixme_codes_strict: ISet.t;
108109
log_levels: int SMap.t;
@@ -224,6 +225,7 @@ let default =
224225
tco_language_feature_logging = false;
225226
tco_timeout = 0;
226227
tco_disallow_invalid_arraykey = true;
228+
tco_constraint_array_index = false;
227229
code_agnostic_fixme = false;
228230
allowed_fixme_codes_strict = ISet.empty;
229231
log_levels = SMap.empty;
@@ -344,6 +346,7 @@ let set
344346
?tco_language_feature_logging
345347
?tco_timeout
346348
?tco_disallow_invalid_arraykey
349+
?tco_constraint_array_index
347350
?code_agnostic_fixme
348351
?allowed_fixme_codes_strict
349352
?log_levels
@@ -500,6 +503,8 @@ let set
500503
setting
501504
tco_disallow_invalid_arraykey
502505
options.tco_disallow_invalid_arraykey;
506+
tco_constraint_array_index =
507+
setting tco_constraint_array_index options.tco_constraint_array_index;
503508
log_levels = setting log_levels options.log_levels;
504509
tco_remote_old_decls_no_limit =
505510
setting

hphp/hack/src/options/globalOptions.mli

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ type t = {
9797
tco_disallow_invalid_arraykey: bool;
9898
(** Flag to disallow using values that get casted to array keys at runtime;
9999
like bools, floats, or null; as array keys. *)
100+
tco_constraint_array_index: bool;
101+
(** Flag to enable the constraint solver to infer that a type can be indexed *)
100102
code_agnostic_fixme: bool;
101103
(** HH_FIXME should silence *any* error, not just the one specified by code *)
102104
allowed_fixme_codes_strict: ISet.t;
@@ -324,6 +326,7 @@ val set :
324326
?tco_language_feature_logging:bool ->
325327
?tco_timeout:int ->
326328
?tco_disallow_invalid_arraykey:bool ->
329+
?tco_constraint_array_index:bool ->
327330
?code_agnostic_fixme:bool ->
328331
?allowed_fixme_codes_strict:ISet.t ->
329332
?log_levels:int SMap.t ->

hphp/hack/src/options/typecheckerOptions.ml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ let timeout t = t.GlobalOptions.tco_timeout
9191

9292
let disallow_invalid_arraykey t = t.GlobalOptions.tco_disallow_invalid_arraykey
9393

94+
let constraint_array_index t = t.GlobalOptions.tco_constraint_array_index
95+
9496
let log_levels t = t.GlobalOptions.log_levels
9597

9698
let remote_old_decls_no_limit t = t.GlobalOptions.tco_remote_old_decls_no_limit

hphp/hack/src/oxidized/gen/global_options.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// This source code is licensed under the MIT license found in the
44
// LICENSE file in the "hack" directory of this source tree.
55
//
6-
// @generated SignedSource<<4bbf7b8ca7578ba93659f67d2b642806>>
6+
// @generated SignedSource<<4e9edccd68800485daea4b4b0079141e>>
77
//
88
// To regenerate this file, run:
99
// hphp/hack/src/oxidized_regen.sh
@@ -166,6 +166,7 @@ pub struct GlobalOptions {
166166
pub tco_language_feature_logging: bool,
167167
pub tco_timeout: isize,
168168
pub tco_disallow_invalid_arraykey: bool,
169+
pub tco_constraint_array_index: bool,
169170
pub code_agnostic_fixme: bool,
170171
pub allowed_fixme_codes_strict: i_set::ISet,
171172
pub log_levels: s_map::SMap<isize>,

hphp/hack/src/oxidized/manual/global_options_impl.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ impl Default for GlobalOptions {
5454
tco_language_feature_logging: false,
5555
tco_timeout: 0,
5656
tco_disallow_invalid_arraykey: false, // true in ocaml, true in .hhconfig
57+
tco_constraint_array_index: false,
5758
code_agnostic_fixme: false,
5859
allowed_fixme_codes_strict: i_set::ISet::new(),
5960
log_levels: s_map::SMap::new(),

hphp/hack/src/utils/hh_config/hh_config.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,8 @@ impl HhConfig {
352352
"disallow_invalid_arraykey",
353353
default.tco_disallow_invalid_arraykey,
354354
)?,
355+
tco_constraint_array_index: hhconfig
356+
.get_bool_or("constraint_array_index", default.code_agnostic_fixme)?,
355357
code_agnostic_fixme: hhconfig
356358
.get_bool_or("code_agnostic_fixme", default.code_agnostic_fixme)?,
357359
allowed_fixme_codes_strict: hhconfig.get_int_set_or(

0 commit comments

Comments
 (0)