[eradicate] no longer add @Strict in the report description

Reviewed By: mbouaziz

Differential Revision: D8519064

fbshipit-source-id: 3c8c439
master
Jeremy Dubreil 7 years ago committed by Facebook Github Bot
parent e5d8f501f4
commit dd25985e67

@ -64,7 +64,7 @@ let is_virtual = function
let check_field_access tenv find_canonical_duplicate curr_pname node instr_ref exp fname ta loc let check_field_access tenv find_canonical_duplicate curr_pname node instr_ref exp fname ta loc
: unit = : unit =
if TypeAnnotation.get_value AnnotatedSignature.Nullable ta then if TypeAnnotation.get_value AnnotatedSignature.Nullable ta then
let origin_descr = TypeAnnotation.descr_origin tenv ta in let origin_descr = TypeAnnotation.descr_origin ta in
report_error tenv find_canonical_duplicate report_error tenv find_canonical_duplicate
(TypeErr.Null_field_access (explain_expr tenv node exp, fname, origin_descr, false)) (TypeErr.Null_field_access (explain_expr tenv node exp, fname, origin_descr, false))
(Some instr_ref) loc curr_pname (Some instr_ref) loc curr_pname
@ -74,7 +74,7 @@ let check_field_access tenv find_canonical_duplicate curr_pname node instr_ref e
let check_array_access tenv find_canonical_duplicate curr_pname node instr_ref array_exp fname ta let check_array_access tenv find_canonical_duplicate curr_pname node instr_ref array_exp fname ta
loc indexed = loc indexed =
if TypeAnnotation.get_value AnnotatedSignature.Nullable ta then if TypeAnnotation.get_value AnnotatedSignature.Nullable ta then
let origin_descr = TypeAnnotation.descr_origin tenv ta in let origin_descr = TypeAnnotation.descr_origin ta in
report_error tenv find_canonical_duplicate report_error tenv find_canonical_duplicate
(TypeErr.Null_field_access (explain_expr tenv node array_exp, fname, origin_descr, indexed)) (TypeErr.Null_field_access (explain_expr tenv node array_exp, fname, origin_descr, indexed))
(Some instr_ref) loc curr_pname (Some instr_ref) loc curr_pname
@ -208,12 +208,12 @@ let check_field_assignment tenv find_canonical_duplicate curr_pdesc node instr_r
if should_report_nullable then AnnotatedSignature.Nullable else AnnotatedSignature.Present if should_report_nullable then AnnotatedSignature.Nullable else AnnotatedSignature.Present
in in
if Models.Inference.enabled then Models.Inference.field_add_nullable_annotation fname ; if Models.Inference.enabled then Models.Inference.field_add_nullable_annotation fname ;
let origin_descr = TypeAnnotation.descr_origin tenv ta_rhs in let origin_descr = TypeAnnotation.descr_origin ta_rhs in
report_error tenv find_canonical_duplicate report_error tenv find_canonical_duplicate
(TypeErr.Field_annotation_inconsistent (ann, fname, origin_descr)) (Some instr_ref) loc (TypeErr.Field_annotation_inconsistent (ann, fname, origin_descr)) (Some instr_ref) loc
curr_pdesc ) ; curr_pdesc ) ;
if should_report_mutable then if should_report_mutable then
let origin_descr = TypeAnnotation.descr_origin tenv ta_rhs in let origin_descr = TypeAnnotation.descr_origin ta_rhs in
report_error tenv find_canonical_duplicate (TypeErr.Field_not_mutable (fname, origin_descr)) report_error tenv find_canonical_duplicate (TypeErr.Field_not_mutable (fname, origin_descr))
(Some instr_ref) loc curr_pdesc (Some instr_ref) loc curr_pdesc
@ -321,7 +321,7 @@ let check_return_annotation tenv find_canonical_duplicate curr_pdesc ret_range
| Some (_, final_ta, _) -> | Some (_, final_ta, _) ->
let final_nullable = TypeAnnotation.get_value AnnotatedSignature.Nullable final_ta in let final_nullable = TypeAnnotation.get_value AnnotatedSignature.Nullable final_ta in
let final_present = TypeAnnotation.get_value AnnotatedSignature.Present final_ta in let final_present = TypeAnnotation.get_value AnnotatedSignature.Present final_ta in
let origin_descr = TypeAnnotation.descr_origin tenv final_ta in let origin_descr = TypeAnnotation.descr_origin final_ta in
let return_not_nullable = let return_not_nullable =
final_nullable && not ret_annotated_nullable && not ret_implicitly_nullable final_nullable && not ret_annotated_nullable && not ret_implicitly_nullable
&& not (return_nonnull_silent && ret_annotated_nonnull) && not (return_nonnull_silent && ret_annotated_nonnull)
@ -367,7 +367,7 @@ let check_call_receiver tenv find_canonical_duplicate curr_pdesc node typestate
if null_method_call then AnnotatedSignature.Nullable else AnnotatedSignature.Present if null_method_call then AnnotatedSignature.Nullable else AnnotatedSignature.Present
in in
let descr = explain_expr tenv node original_this_e in let descr = explain_expr tenv node original_this_e in
let origin_descr = TypeAnnotation.descr_origin tenv this_ta in let origin_descr = TypeAnnotation.descr_origin this_ta in
report_error tenv find_canonical_duplicate report_error tenv find_canonical_duplicate
(TypeErr.Call_receiver_annotation_inconsistent (ann, descr, callee_pname, origin_descr)) (TypeErr.Call_receiver_annotation_inconsistent (ann, descr, callee_pname, origin_descr))
(Some instr_ref) loc curr_pdesc (Some instr_ref) loc curr_pdesc
@ -395,7 +395,7 @@ let check_call_parameters tenv find_canonical_duplicate curr_pdesc node callee_a
| None -> | None ->
"formal parameter " ^ Mangled.to_string s1 "formal parameter " ^ Mangled.to_string s1
in in
let origin_descr = TypeAnnotation.descr_origin tenv ta2 in let origin_descr = TypeAnnotation.descr_origin ta2 in
let callee_loc = callee_attributes.ProcAttributes.loc in let callee_loc = callee_attributes.ProcAttributes.loc in
report_error tenv find_canonical_duplicate report_error tenv find_canonical_duplicate
(TypeErr.Parameter_annotation_inconsistent (TypeErr.Parameter_annotation_inconsistent

@ -31,8 +31,8 @@ let set_nullable b = set_value Nullable b
let set_present b = set_value Present b let set_present b = set_value Present b
let descr_origin tenv ta = let descr_origin ta =
let descr_opt = TypeOrigin.get_description tenv ta.origin in let descr_opt = TypeOrigin.get_description ta.origin in
match descr_opt with match descr_opt with
| None -> | None ->
("", None, None) ("", None, None)

@ -13,7 +13,7 @@ type t [@@deriving compare]
val const : AnnotatedSignature.annotation -> bool -> TypeOrigin.t -> t val const : AnnotatedSignature.annotation -> bool -> TypeOrigin.t -> t
val descr_origin : Tenv.t -> t -> TypeErr.origin_descr val descr_origin : t -> TypeErr.origin_descr
(** Human-readable description of the origin of a nullable value. *) (** Human-readable description of the origin of a nullable value. *)
val from_item_annotation : Annot.Item.t -> TypeOrigin.t -> t val from_item_annotation : Annot.Item.t -> TypeOrigin.t -> t

@ -31,12 +31,6 @@ end
module InstrRef : InstrRefT module InstrRef : InstrRefT
module Strict : sig
val signature_get_strict : Tenv.t -> AnnotatedSignature.t -> Annot.t option
end
(* Strict *)
type origin_descr = string * Location.t option * AnnotatedSignature.t option type origin_descr = string * Location.t option * AnnotatedSignature.t option
(* callee signature *) (* callee signature *)

@ -45,7 +45,7 @@ let rec to_string = function
"Undef" "Undef"
let get_description tenv origin = let get_description origin =
let atline loc = " at line " ^ string_of_int loc.Location.line in let atline loc = " at line " ^ string_of_int loc.Location.line in
match origin with match origin with
| Const loc -> | Const loc ->
@ -55,25 +55,12 @@ let get_description tenv origin =
| Formal s -> | Formal s ->
Some ("method parameter " ^ Mangled.to_string s, None, None) Some ("method parameter " ^ Mangled.to_string s, None, None)
| Proc po -> | Proc po ->
let strict =
match TypeErr.Strict.signature_get_strict tenv po.annotated_signature with
| Some ann
-> (
let str = "@Strict" in
match ann.Annot.parameters with
| par1 :: _ ->
Printf.sprintf "%s(%s) " str par1
| [] ->
Printf.sprintf "%s " str )
| None ->
""
in
let modelled_in = let modelled_in =
if Models.is_modelled_nullable po.pname then " modelled in " ^ ModelTables.this_file if Models.is_modelled_nullable po.pname then " modelled in " ^ ModelTables.this_file
else "" else ""
in in
let description = let description =
Printf.sprintf "call to %s%s%s%s" strict Printf.sprintf "call to %s%s%s"
(Typ.Procname.to_simplified_string po.pname) (Typ.Procname.to_simplified_string po.pname)
modelled_in (atline po.loc) modelled_in (atline po.loc)
in in

@ -27,7 +27,7 @@ type t =
val equal : t -> t -> bool val equal : t -> t -> bool
val get_description : Tenv.t -> t -> TypeErr.origin_descr option val get_description : t -> TypeErr.origin_descr option
(** Get a description to be used for error messages. *) (** Get a description to be used for error messages. *)
val join : t -> t -> t val join : t -> t -> t

Loading…
Cancel
Save