Skip to content

Commit

Permalink
Kill tco_report_pos_from_reason
Browse files Browse the repository at this point in the history
Summary: Removes the `tco_report_pos_from_reason` typechecker option and removes this conditioning from error reporting code

Reviewed By: andrewjkennedy

Differential Revision: D68953568

fbshipit-source-id: 4311dd8c6428bb94d3c822c1fe8bdeefc70bd617
  • Loading branch information
Michael Thomas authored and facebook-github-bot committed Jan 31, 2025
1 parent 89d1b6e commit 485b190
Show file tree
Hide file tree
Showing 15 changed files with 6 additions and 51 deletions.
3 changes: 0 additions & 3 deletions hphp/hack/src/client_and_server/serverConfig.ml
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,6 @@ let load_config (config : Config_file_common.t) (options : GlobalOptions.t) :
?tco_error_php_lambdas:(bool_opt "error_php_lambdas" config)
?tco_disallow_discarded_nullable_awaitables:
(bool_opt "disallow_discarded_nullable_awaitables" config)
?tco_report_pos_from_reason:(bool_opt "report_pos_from_reason" config)
?tco_typecheck_sample_rate:(float_opt "typecheck_sample_rate" config)
?tco_enable_sound_dynamic:(bool_opt "enable_sound_dynamic_type" config)
?tco_pessimise_builtins:(bool_opt "pessimise_builtins" config)
Expand Down Expand Up @@ -654,8 +653,6 @@ let load
in
Errors.allowed_fixme_codes_strict :=
GlobalOptions.allowed_fixme_codes_strict global_opts;
Errors.report_pos_from_reason :=
TypecheckerOptions.report_pos_from_reason global_opts;
Errors.code_agnostic_fixme := GlobalOptions.code_agnostic_fixme global_opts;
( {
version;
Expand Down
9 changes: 1 addition & 8 deletions hphp/hack/src/errors/errors.ml
Original file line number Diff line number Diff line change
Expand Up @@ -556,9 +556,7 @@ let format_summary
else
None

let report_pos_from_reason = ref false

let to_string error = User_error.to_string !report_pos_from_reason error
let to_string error = User_error.to_string error

let log_unexpected error path desc =
HackEventLogger.invariant_violation_bug
Expand Down Expand Up @@ -787,11 +785,6 @@ let try_apply_fixme pos code severity : fixme_outcome =
Not_fixmed (Some { explanation; fixme_pos })
else if Relative_path.(is_hhi (prefix (Pos.filename pos))) then
Fixmed
else if !report_pos_from_reason && Pos.get_from_reason pos then
let explanation =
"You cannot use `HH_FIXME` or `HH_IGNORE_ERROR` comments to suppress an error whose position was derived from reason information"
in
Not_fixmed (Some { explanation; fixme_pos })
else if forbidden_decl_fixme then
let explanation =
Printf.sprintf
Expand Down
2 changes: 0 additions & 2 deletions hphp/hack/src/errors/errors.mli
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@ val add_error : error -> unit
(* Error codes that can be suppressed in strict mode with a FIXME based on configuration. *)
val allowed_fixme_codes_strict : ISet.t ref

val report_pos_from_reason : bool ref

val is_strict_code : int -> bool

val set_allow_errors_in_default_path : bool -> unit
Expand Down
12 changes: 2 additions & 10 deletions hphp/hack/src/errors/user_error.ml
Original file line number Diff line number Diff line change
Expand Up @@ -254,32 +254,24 @@ let error_code_to_string error_code =
path/to/other/file.php ...
And this too
*)
let to_string
report_pos_from_reason { severity; code; claim; reasons; custom_msgs; _ } =
let to_string { severity; code; claim; reasons; custom_msgs; _ } =
let buf = Buffer.create 50 in
let (pos1, msg1) = claim in
Buffer.add_string
buf
begin
let error_code = error_code_to_string code in
let reason_msg =
if report_pos_from_reason && Pos.get_from_reason pos1 then
" [FROM REASON INFO]"
else
""
in
Printf.sprintf
(* /!\ WARNING!!!!!
Changing this might break emacs and vim.
These are not officially supported, but breaking will piss off users.
Fix Emacs at fbcode/emacs_config/emacs-packages/compile-mode-regexes.el
Fix Vim at fbcode/shellconfigs/rc_deprecated/vim/plugin/hack.vim, variable hack_errorformat *)
"%s: %s\n%s (%s)%s\n"
"%s: %s\n%s (%s)\n"
(Severity.to_all_caps_string severity)
(Pos.string pos1)
msg1
error_code
reason_msg
end;
let (_ : unit) =
List.iter reasons ~f:(fun (p, w) ->
Expand Down
2 changes: 1 addition & 1 deletion hphp/hack/src/errors/user_error.mli
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ val error_code_to_string : int -> string
path/to/other/file.php pos...
And this too
*)
val to_string : bool -> (Pos.absolute, Pos.absolute) t -> string
val to_string : (Pos.absolute, Pos.absolute) t -> string

val to_json :
human_formatter:(('a Pos.pos, 'a Pos.pos) t -> string) option ->
Expand Down
2 changes: 0 additions & 2 deletions hphp/hack/src/hh_single_ai.ml
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,6 @@ let parse_options () =
in
Errors.allowed_fixme_codes_strict :=
GlobalOptions.allowed_fixme_codes_strict tcopt;
Errors.report_pos_from_reason :=
TypecheckerOptions.report_pos_from_reason tcopt;
( { files = fns; extra_builtins = !extra_builtins; ai_options; tcopt },
Ai_options.modify_shared_mem ai_options SharedMem.default_config )

Expand Down
3 changes: 0 additions & 3 deletions hphp/hack/src/hh_single_type_check.ml
Original file line number Diff line number Diff line change
Expand Up @@ -946,7 +946,6 @@ let parse_options () =
!disallow_discarded_nullable_awaitables
~glean_reponame:!glean_reponame
~tco_higher_kinded_types:!enable_higher_kinded_types
~tco_report_pos_from_reason:!report_pos_from_reason
~tco_enable_sound_dynamic:true
~tco_skip_check_under_dynamic:!skip_check_under_dynamic
~tco_global_access_check_enabled:!enable_global_access_check
Expand Down Expand Up @@ -975,8 +974,6 @@ let parse_options () =

Errors.allowed_fixme_codes_strict :=
GlobalOptions.allowed_fixme_codes_strict tcopt;
Errors.report_pos_from_reason :=
TypecheckerOptions.report_pos_from_reason tcopt;

let tco_experimental_features =
tcopt.GlobalOptions.tco_experimental_features
Expand Down
5 changes: 0 additions & 5 deletions hphp/hack/src/options/globalOptions.ml
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ type t = {
tco_error_php_lambdas: bool;
tco_disallow_discarded_nullable_awaitables: bool;
tco_higher_kinded_types: bool;
tco_report_pos_from_reason: bool;
tco_typecheck_sample_rate: float;
tco_enable_sound_dynamic: bool;
tco_pessimise_builtins: bool;
Expand Down Expand Up @@ -252,7 +251,6 @@ let default =
tco_error_php_lambdas = false;
tco_disallow_discarded_nullable_awaitables = false;
tco_higher_kinded_types = false;
tco_report_pos_from_reason = false;
tco_typecheck_sample_rate = 1.0;
tco_enable_sound_dynamic = false;
tco_pessimise_builtins = false;
Expand Down Expand Up @@ -361,7 +359,6 @@ let set
?tco_error_php_lambdas
?tco_disallow_discarded_nullable_awaitables
?tco_higher_kinded_types
?tco_report_pos_from_reason
?tco_typecheck_sample_rate
?tco_enable_sound_dynamic
?tco_pessimise_builtins
Expand Down Expand Up @@ -555,8 +552,6 @@ let set
options.tco_disallow_discarded_nullable_awaitables;
tco_higher_kinded_types =
setting tco_higher_kinded_types options.tco_higher_kinded_types;
tco_report_pos_from_reason =
setting tco_report_pos_from_reason options.tco_report_pos_from_reason;
tco_typecheck_sample_rate =
setting tco_typecheck_sample_rate options.tco_typecheck_sample_rate;
tco_enable_sound_dynamic =
Expand Down
4 changes: 0 additions & 4 deletions hphp/hack/src/options/globalOptions.mli
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,6 @@ type t = {
(** Flag to error on using discarded nullable awaitables *)
tco_higher_kinded_types: bool;
(** Controls if higher-kinded types are supported *)
tco_report_pos_from_reason: bool;
(** If set, then positions derived from reason information are tainted, and primary errors
with such positions are flagged *)
tco_typecheck_sample_rate: float;
(** Type check this proportion of all files. Default is 1.0.
DO NOT set to any other value except for testing purposes. *)
Expand Down Expand Up @@ -337,7 +334,6 @@ val set :
?tco_error_php_lambdas:bool ->
?tco_disallow_discarded_nullable_awaitables:bool ->
?tco_higher_kinded_types:bool ->
?tco_report_pos_from_reason:bool ->
?tco_typecheck_sample_rate:float ->
?tco_enable_sound_dynamic:bool ->
?tco_pessimise_builtins:bool ->
Expand Down
2 changes: 0 additions & 2 deletions hphp/hack/src/options/typecheckerOptions.ml
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,6 @@ let is_systemlib t = t.GlobalOptions.po.ParserOptions.is_systemlib

let higher_kinded_types t = t.GlobalOptions.tco_higher_kinded_types

let report_pos_from_reason t = t.GlobalOptions.tco_report_pos_from_reason

let enable_sound_dynamic t = t.GlobalOptions.tco_enable_sound_dynamic

let enable_no_auto_dynamic t = t.GlobalOptions.tco_enable_no_auto_dynamic
Expand Down
3 changes: 1 addition & 2 deletions hphp/hack/src/oxidized/gen/global_options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// This source code is licensed under the MIT license found in the
// LICENSE file in the "hack" directory of this source tree.
//
// @generated SignedSource<<7febc72690d173ffab4606dd14aed244>>
// @generated SignedSource<<c0812cd2d1206e4b9bc28e4e385e5d01>>
//
// To regenerate this file, run:
// hphp/hack/src/oxidized_regen.sh
Expand Down Expand Up @@ -204,7 +204,6 @@ pub struct GlobalOptions {
pub tco_error_php_lambdas: bool,
pub tco_disallow_discarded_nullable_awaitables: bool,
pub tco_higher_kinded_types: bool,
pub tco_report_pos_from_reason: bool,
pub tco_typecheck_sample_rate: f64,
pub tco_enable_sound_dynamic: bool,
pub tco_pessimise_builtins: bool,
Expand Down
1 change: 0 additions & 1 deletion hphp/hack/src/oxidized/manual/global_options_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ impl Default for GlobalOptions {
symbol_write_reindexed_out: None,
symbol_write_sym_hash_out: false,
tco_higher_kinded_types: false,
tco_report_pos_from_reason: false,
tco_typecheck_sample_rate: 1.0,
tco_enable_sound_dynamic: false,
tco_pessimise_builtins: false,
Expand Down
1 change: 0 additions & 1 deletion hphp/hack/src/package/packageConfig.ml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ let parse (package_v2 : bool) (strict : bool) (path : string) =
in
User_error.(
to_string
true
(to_absolute
Parsing_error.(
to_user_error @@ Package_config_error { pos; msg; reasons }))))
Expand Down
7 changes: 1 addition & 6 deletions hphp/hack/src/typing/typing_reason.ml
Original file line number Diff line number Diff line change
Expand Up @@ -2196,12 +2196,7 @@ let rec to_json_help : type a. a t_ -> Hh_json.json list -> Hh_json.json list =
and to_json : type a. a t_ -> Hh_json.json =
(fun t -> Hh_json.JSON_Array (List.rev @@ to_json_help t []))

let to_pos : type ph. ph t_ -> Pos_or_decl.t =
fun r ->
if !Errors.report_pos_from_reason then
Pos_or_decl.set_from_reason (to_raw_pos r)
else
to_raw_pos r
let to_pos : type ph. ph t_ -> Pos_or_decl.t = (fun r -> to_raw_pos r)

let rec flow_contains_tyvar = function
| Flow
Expand Down
1 change: 0 additions & 1 deletion hphp/hack/src/utils/hh_config/hh_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,6 @@ impl HhConfig {
tco_disallow_discarded_nullable_awaitables: default
.tco_disallow_discarded_nullable_awaitables,
tco_higher_kinded_types: default.tco_higher_kinded_types,
tco_report_pos_from_reason: default.tco_report_pos_from_reason,
tco_typecheck_sample_rate: hhconfig
.get_float_or("typecheck_sample_rate", default.tco_typecheck_sample_rate)?,
tco_enable_sound_dynamic: hhconfig.get_bool_or(
Expand Down

0 comments on commit 485b190

Please sign in to comment.