From 94c38449779095043a00edf19d7e231cdacff2de Mon Sep 17 00:00:00 2001 From: Vassil Mladenov Date: Tue, 12 May 2020 22:17:36 -0700 Subject: [PATCH] Split error codes for read/write on array access and object access Summary: This diff splits the codes for read and write on certain array access and object access expressions so that the former can be tracked and eliminated. The motivation is that when there's a error on a read that is fixme'd, it generates a Tany (Terr) that flows into other types in a function body. Reviewed By: Wilfred Differential Revision: D21421657 fbshipit-source-id: ed89bc6cd81c124f40b84c269109ca76f4e56290 --- hphp/hack/src/errors/error_codes.ml | 14 +++-- hphp/hack/src/errors/errors.ml | 44 +++++++++++---- hphp/hack/src/errors/errors.mli | 35 ++++++++++-- hphp/hack/src/typing/typing_array_access.ml | 35 ++++++------ hphp/hack/src/typing/typing_object_get.ml | 66 ++++++++++++++++------ hphp/hack/src/typing/typing_taccess.ml | 4 +- hphp/hack/test/errors/error_map.ml | 12 ++-- .../test/typecheck/array_heterogeneous.php.exp | 2 +- hphp/hack/test/typecheck/fake_members11.php.exp | 2 +- .../invalid_arraykey/darray_assign_bad.php.exp | 2 +- .../invalid_arraykey/invalid_arraykey.php.exp | 12 ++-- ...like_types.exp => stack_overflow_array.php.exp} | 14 ++--- .../stack_overflow_array.php.like_types.exp | 12 ++-- hphp/hack/test/typecheck/test_array13.php.exp | 2 +- hphp/hack/test/unit/utils/errors_test.ml | 8 +-- 15 files changed, 177 insertions(+), 87 deletions(-) copy hphp/hack/test/typecheck/new_inference/eager_solve/{stack_overflow_array.php.like_types.exp => stack_overflow_array.php.exp} (93%) diff --git a/hphp/hack/src/errors/error_codes.ml b/hphp/hack/src/errors/error_codes.ml index 59fb351197f..94bb2343a1b 100644 --- a/hphp/hack/src/errors/error_codes.ml +++ b/hphp/hack/src/errors/error_codes.ml @@ -265,7 +265,7 @@ module Typing = struct | UninstantiableClass | AnonymousRecursiveDEPRECATED | AnonymousRecursiveCallDEPRECATED - | ArrayAccess + | ArrayAccessRead | ArrayAppend | ArrayCast | ArrayGetArity @@ -322,9 +322,9 @@ module Typing = struct | SelfOutsideClass | NewStaticInconsistent | StaticOutsideClass - | NonObjectMember + | NonObjectMemberRead | NullContainer - | NullMember + | NullMemberRead | NullableParameterDEPRECATED | OptionReturnOnlyTypehint | ObjectString @@ -558,7 +558,7 @@ module Typing = struct | OptionNull | UnknownObjectMember | UnknownType - | InvalidArrayKey + | InvalidArrayKeyRead | ReferenceExprNotFunctionArgDEPRECATED | RedundantRxCondition | RedeclaringMissingMethod @@ -629,7 +629,11 @@ module Typing = struct | RedundantGeneric | PocketUniversesInvalidUpperBounds | PocketUniversesRefinement - | PocketUniversesReservedSyntax (* EXTEND HERE WITH NEW VALUES IF NEEDED *) + | PocketUniversesReservedSyntax + | ArrayAccessWrite + | InvalidArrayKeyWrite + | NullMemberWrite + | NonObjectMemberWrite (* EXTEND HERE WITH NEW VALUES IF NEEDED *) [@@deriving enum, show { with_path = false }] let err_code = to_enum diff --git a/hphp/hack/src/errors/errors.ml b/hphp/hack/src/errors/errors.ml index 31285fe36e3..7258a985a82 100644 --- a/hphp/hack/src/errors/errors.ml +++ b/hphp/hack/src/errors/errors.ml @@ -2863,9 +2863,9 @@ let undefined_field ~use_pos ~name ~shape_type_pos = (shape_type_pos, "Definition is here"); ] -let array_access pos1 pos2 ty = +let array_access code pos1 pos2 ty = add_list - (Typing.err_code Typing.ArrayAccess) + (Typing.err_code code) ( (pos1, "This is not an object of type KeyedContainer, this is " ^ ty) :: ( if not (phys_equal pos2 Pos.none) then @@ -2873,6 +2873,10 @@ let array_access pos1 pos2 ty = else [] ) ) +let array_access_read = array_access Typing.ArrayAccessRead + +let array_access_write = array_access Typing.ArrayAccessWrite + let keyset_set pos1 pos2 = add_list (Typing.err_code Typing.KeysetSet) @@ -3749,7 +3753,7 @@ let dynamic_redeclared_as_static (Typing.err_code Typing.StaticDynamic) [(static_position, msg_static); (dyn_position, msg_dynamic)] -let null_member ~is_method s pos r = +let null_member code ~is_method s pos r = let msg = Printf.sprintf "You are trying to access the %s '%s' but this object can be null." @@ -3759,10 +3763,14 @@ let null_member ~is_method s pos r = "property" ) s in - add_list (Typing.err_code Typing.NullMember) ([(pos, msg)] @ r) + add_list (Typing.err_code code) ([(pos, msg)] @ r) + +let null_member_read = null_member Typing.NullMemberRead + +let null_member_write = null_member Typing.NullMemberWrite (* Trying to access a member on a mixed or nonnull value. *) -let top_member ~is_method ~is_nullable s pos1 ty pos2 = +let top_member null_code nonnull_code ~is_method ~is_nullable s pos1 ty pos2 = let msg = Printf.sprintf "You are trying to access the %s '%s' but this is %s. Use a specific class or interface name." @@ -3776,13 +3784,19 @@ let top_member ~is_method ~is_nullable s pos1 ty pos2 = add_list (Typing.err_code ( if is_nullable then - Typing.NullMember + null_code else - Typing.NonObjectMember )) + nonnull_code )) [(pos1, msg); (pos2, "Definition is here")] +let top_member_read = + top_member Typing.NullMemberRead Typing.NonObjectMemberRead + +let top_member_write = + top_member Typing.NullMemberWrite Typing.NonObjectMemberWrite + let non_object_member - ~is_method s pos1 ty pos2 (on_error : typing_error_callback) = + code ~is_method s pos1 ty pos2 (on_error : typing_error_callback) = let msg_start = Printf.sprintf "You are trying to access the %s '%s' but this is %s" @@ -3800,9 +3814,13 @@ let non_object_member msg_start in on_error - ~code:(Typing.err_code Typing.NonObjectMember) + ~code:(Typing.err_code code) [(pos1, msg); (pos2, "Definition is here")] +let non_object_member_read = non_object_member Typing.NonObjectMemberRead + +let non_object_member_write = non_object_member Typing.NonObjectMemberRead + let unknown_object_member ~is_method s pos r = let msg = Printf.sprintf @@ -4899,15 +4917,19 @@ let redundant_rx_condition pos = pos "Reactivity condition for this method is always true, consider removing it." -let invalid_arraykey pos (cpos, ctype) (kpos, ktype) = +let invalid_arraykey code pos (cpos, ctype) (kpos, ktype) = add_list - (Typing.err_code Typing.InvalidArrayKey) + (Typing.err_code code) [ (pos, "This value is not a valid key type for this container"); (cpos, "This container is " ^ ctype); (kpos, String.capitalize ktype ^ " cannot be used as a key for " ^ ctype); ] +let invalid_arraykey_read = invalid_arraykey Typing.InvalidArrayKeyRead + +let invalid_arraykey_write = invalid_arraykey Typing.InvalidArrayKeyWrite + let invalid_sub_string pos ty = add (Typing.err_code Typing.InvalidSubString) pos @@ "Expected an object convertible to string but got " diff --git a/hphp/hack/src/errors/errors.mli b/hphp/hack/src/errors/errors.mli index 05cdd98edf8..34d3752c334 100644 --- a/hphp/hack/src/errors/errors.mli +++ b/hphp/hack/src/errors/errors.mli @@ -386,7 +386,9 @@ val typing_error : Pos.t -> string -> unit val undefined_field : use_pos:Pos.t -> name:string -> shape_type_pos:Pos.t -> unit -val array_access : Pos.t -> Pos.t -> string -> unit +val array_access_read : Pos.t -> Pos.t -> string -> unit + +val array_access_write : Pos.t -> Pos.t -> string -> unit val keyset_set : Pos.t -> Pos.t -> unit @@ -535,10 +537,22 @@ val static_redeclared_as_dynamic : val dynamic_redeclared_as_static : Pos.t -> Pos.t -> string -> elt_type:[ `Method | `Property ] -> unit -val null_member : +val null_member_read : + is_method:bool -> string -> Pos.t -> (Pos.t * string) list -> unit + +val null_member_write : is_method:bool -> string -> Pos.t -> (Pos.t * string) list -> unit -val top_member : +val top_member_read : + is_method:bool -> + is_nullable:bool -> + string -> + Pos.t -> + string -> + Pos.t -> + unit + +val top_member_write : is_method:bool -> is_nullable:bool -> string -> @@ -547,7 +561,16 @@ val top_member : Pos.t -> unit -val non_object_member : +val non_object_member_read : + is_method:bool -> + string -> + Pos.t -> + string -> + Pos.t -> + typing_error_callback -> + unit + +val non_object_member_write : is_method:bool -> string -> Pos.t -> @@ -1170,7 +1193,9 @@ val ambiguous_object_access : val unserializable_type : Pos.t -> string -> unit -val invalid_arraykey : Pos.t -> Pos.t * string -> Pos.t * string -> unit +val invalid_arraykey_read : Pos.t -> Pos.t * string -> Pos.t * string -> unit + +val invalid_arraykey_write : Pos.t -> Pos.t * string -> Pos.t * string -> unit val invalid_arraykey_constraint : Pos.t -> string -> unit diff --git a/hphp/hack/src/typing/typing_array_access.ml b/hphp/hack/src/typing/typing_array_access.ml index 3d2d856529b..fdda6ea2979 100644 --- a/hphp/hack/src/typing/typing_array_access.ml +++ b/hphp/hack/src/typing/typing_array_access.ml @@ -25,7 +25,7 @@ open String.Replace_polymorphic_compare let err_witness env p = TUtils.terr env (Reason.Rwitness p) let error_array env p ty = - Errors.array_access p (get_pos ty) (Typing_print.error env ty); + Errors.array_access_read p (get_pos ty) (Typing_print.error env ty); (env, err_witness env p) let error_const_mutation env p ty = @@ -123,7 +123,7 @@ let widen_for_array_get ~lhs_of_null_coalesce ~expr_pos index_expr env ty = (* Check that an index to a map-like collection passes the basic test of * being a subtype of arraykey *) -let check_arraykey_index env pos container_ty index_ty = +let check_arraykey_index error env pos container_ty index_ty = if TypecheckerOptions.disallow_invalid_arraykey (Env.get_tcopt env) then let (env, container_ty) = Env.expand_type env container_ty in let reason = @@ -141,13 +141,16 @@ let check_arraykey_index env pos container_ty index_ty = index_ty { et_type = ty_arraykey; et_enforced = true } (fun ?code:_ _ -> - Errors.invalid_arraykey - pos - (info_of_type container_ty) - (info_of_type index_ty)) + error pos (info_of_type container_ty) (info_of_type index_ty)) else env +let check_arraykey_index_read = + check_arraykey_index Errors.invalid_arraykey_read + +let check_arraykey_index_write = + check_arraykey_index Errors.invalid_arraykey_write + let rec array_get ~array_pos ~expr_pos @@ -289,7 +292,7 @@ let rec array_get String.equal cn SN.Collections.cDict || String.equal cn SN.Collections.cKeyset then - check_arraykey_index env expr_pos ty1 ty2 + check_arraykey_index_read env expr_pos ty1 ty2 else type_index env expr_pos ty2 k (Reason.index_class cn) in @@ -315,7 +318,7 @@ let rec array_get let any = err_witness env expr_pos in (any, any) in - let env = check_arraykey_index env expr_pos ty1 ty2 in + let env = check_arraykey_index_read env expr_pos ty1 ty2 in (env, v) | Tclass (((_, cn) as id), _, argl) when (not is_lvalue) @@ -338,7 +341,7 @@ let rec array_get error_const_mutation env expr_pos ty1 | Tdarray (_k, v) | Tvarray_or_darray (_k, v) -> - let env = check_arraykey_index env expr_pos ty1 ty2 in + let env = check_arraykey_index_read env expr_pos ty1 ty2 in (env, v) | Terr -> (env, err_witness env expr_pos) | Tdynamic -> (env, ty1) @@ -690,7 +693,7 @@ let assign_array_get ~array_pos ~expr_pos ur env ty1 key tkey ty2 = let (env, tv') = Typing_union.union env tv ty2 in (env, mk (r, Tclass (id, e, [tv']))) | Tclass (((_, cn) as id), _, argl) when cn = SN.Collections.cMap -> - let env = check_arraykey_index env expr_pos ety1 tkey in + let env = check_arraykey_index_write env expr_pos ety1 tkey in let (tk, tv) = match argl with | [tk; tv] -> (tk, tv) @@ -706,7 +709,7 @@ let assign_array_get ~array_pos ~expr_pos ur env ty1 key tkey ty2 = (env, ety1) | Tclass (((_, cn) as id), e, argl) when String.equal cn SN.Collections.cDict -> - let env = check_arraykey_index env expr_pos ety1 tkey in + let env = check_arraykey_index_write env expr_pos ety1 tkey in let (tk, tv) = match argl with | [tk; tv] -> (tk, tv) @@ -734,12 +737,12 @@ let assign_array_get ~array_pos ~expr_pos ur env ty1 key tkey ty2 = (Typing_print.error env ety1); error | Tdarray (tk, tv) -> - let env = check_arraykey_index env expr_pos ety1 tkey in + let env = check_arraykey_index_write env expr_pos ety1 tkey in let (env, tk') = Typing_union.union env tk tkey in let (env, tv') = Typing_union.union env tv ty2 in (env, mk (r, Tdarray (tk', tv'))) | Tvarray_or_darray (tk, tv) -> - let env = check_arraykey_index env expr_pos ety1 tkey in + let env = check_arraykey_index_write env expr_pos ety1 tkey in let (env, tk') = Typing_union.union env tk tkey in let (env, tv') = Typing_union.union env tv ty2 in (env, mk (r, Tvarray_or_darray (tk', tv'))) @@ -782,8 +785,8 @@ let assign_array_get ~array_pos ~expr_pos ur env ty1 key tkey ty2 = (env, mk (r, Tshape (shape_kind, fdm'))) end | Tobject -> - if Partial.should_check_error (Env.get_mode env) 4005 then ( - Errors.array_access + if Partial.should_check_error (Env.get_mode env) 4370 then ( + Errors.array_access_write expr_pos (Reason.to_pos r) (Typing_print.error env ety1); @@ -803,7 +806,7 @@ let assign_array_get ~array_pos ~expr_pos ur env ty1 key tkey ty2 = | Tclass _ | Tpu _ | Tpu_type_access _ -> - Errors.array_access + Errors.array_access_write expr_pos (Reason.to_pos r) (Typing_print.error env ety1); diff --git a/hphp/hack/src/typing/typing_object_get.ml b/hphp/hack/src/typing/typing_object_get.ml index 7bcb38943ed..108970dfc2b 100644 --- a/hphp/hack/src/typing/typing_object_get.ml +++ b/hphp/hack/src/typing/typing_object_get.ml @@ -167,6 +167,7 @@ and obj_get_concrete_ty on_error; } in + let read_context = Option.is_none coerce_from_ty in let (env, concrete_ty) = Env.expand_type env concrete_ty in match deref concrete_ty with | (r, Tclass (x, exact, paraml)) -> @@ -378,7 +379,13 @@ and obj_get_concrete_ty | (_, Terr) -> default () | (_, Tnonnull) -> - Errors.top_member + let err = + if read_context then + Errors.top_member_read + else + Errors.top_member_write + in + err ~is_method ~is_nullable:false id_str @@ -387,7 +394,13 @@ and obj_get_concrete_ty (get_pos concrete_ty); default () | _ -> - Errors.non_object_member + let err = + if read_context then + Errors.non_object_member_read + else + Errors.non_object_member_write + in + err ~is_method id_str id_pos @@ -516,7 +529,7 @@ and obj_get_ ty1 Errors.unify_error in - let nullable_obj_get ty = + let nullable_obj_get ~read_context ty = match nullsafe with | Some p1 -> let (env, (method_, tal)) = @@ -545,7 +558,13 @@ and obj_get_ begin match get_node opt_ty with | Tnonnull -> - Errors.top_member + let err = + if read_context then + Errors.top_member_read + else + Errors.top_member_write + in + err ~is_method ~is_nullable:true id_str @@ -553,20 +572,27 @@ and obj_get_ (Typing_print.error env ety1) (Reason.to_pos r) | _ -> - Errors.null_member - ~is_method - id_str - id_pos - (Reason.to_string "This can be null" r) + let err = + if read_context then + Errors.null_member_read + else + Errors.null_member_write + in + err ~is_method id_str id_pos (Reason.to_string "This can be null" r) end | (r, _) -> - Errors.null_member - ~is_method - id_str - id_pos - (Reason.to_string "This can be null" r)); + let err = + if read_context then + Errors.null_member_read + else + Errors.null_member_write + in + err ~is_method id_str id_pos (Reason.to_string "This can be null" r)); (env, (TUtils.terr env (get_reason ety1), [])) in + (* coerce_from_ty is used to store the source type for an assignment, so it + * is a useful marker for whether we're reading or writing *) + let read_context = Option.is_none coerce_from_ty in match deref ety1 with | (r, Tunion tyl) -> let (env, resultl) = @@ -693,7 +719,13 @@ and obj_get_ begin match resl with | [] -> - Errors.non_object_member + let err = + if read_context then + Errors.non_object_member_read + else + Errors.non_object_member_write + in + err ~is_method id_str id_pos @@ -713,10 +745,10 @@ and obj_get_ ) else res end - | (_, Toption ty) -> nullable_obj_get ty + | (_, Toption ty) -> nullable_obj_get ~read_context ty | (r, Tprim Tnull) -> let ty = mk (r, Tunion []) in - nullable_obj_get ty + nullable_obj_get ~read_context ty (* We are trying to access a member through a value of unknown type *) | (r, Tvar _) -> Errors.unknown_object_member diff --git a/hphp/hack/src/typing/typing_taccess.ml b/hphp/hack/src/typing/typing_taccess.ml index 2fde4c9f365..b9378bf060e 100644 --- a/hphp/hack/src/typing/typing_taccess.ml +++ b/hphp/hack/src/typing/typing_taccess.ml @@ -270,7 +270,7 @@ let rec expand ctx env root = let err () = let (pos, tconst) = ctx.id in let ty = Typing_print.error env root in - Errors.non_object_member + Errors.non_object_member_read ~is_method:false tconst (get_pos root) @@ -330,7 +330,7 @@ let rec expand ctx env root = let (pos, tconst) = ctx.id in let ty = Typing_print.error env root in raise_error (fun () -> - Errors.non_object_member + Errors.non_object_member_read ~is_method:false tconst pos diff --git a/hphp/hack/test/errors/error_map.ml b/hphp/hack/test/errors/error_map.ml index bf861d7612d..4aa10d4698f 100644 --- a/hphp/hack/test/errors/error_map.ml +++ b/hphp/hack/test/errors/error_map.ml @@ -256,7 +256,7 @@ AbstractClassFinalDEPRECATED = 4001 UninstantiableClass = 4002 AnonymousRecursiveDEPRECATED = 4003 AnonymousRecursiveCallDEPRECATED = 4004 -ArrayAccess = 4005 +ArrayAccessRead = 4005 ArrayAppend = 4006 ArrayCast = 4007 ArrayGetArity = 4008 @@ -313,9 +313,9 @@ NegativeTupleIndexDEPRECATED = 4058 SelfOutsideClass = 4059 NewStaticInconsistent = 4060 StaticOutsideClass = 4061 -NonObjectMember = 4062 +NonObjectMemberRead = 4062 NullContainer = 4063 -NullMember = 4064 +NullMemberRead = 4064 NullableParameterDEPRECATED = 4065 OptionReturnOnlyTypehint = 4066 ObjectString = 4067 @@ -549,7 +549,7 @@ InvalidMutabilityFlavorInAssignment = 4294 OptionNull = 4295 UnknownObjectMember = 4296 UnknownType = 4297 -InvalidArrayKey = 4298 +InvalidArrayKeyRead = 4298 ReferenceExprNotFunctionArgDEPRECATED = 4299 RedundantRxCondition = 4300 RedeclaringMissingMethod = 4301 @@ -621,4 +621,8 @@ RedundantGeneric = 4366 PocketUniversesInvalidUpperBounds = 4367 PocketUniversesRefinement = 4368 PocketUniversesReservedSyntax = 4369 +ArrayAccessWrite = 4370 +InvalidArrayKeyWrite = 4371 +NullMemberWrite = 4372 +NonObjectMemberWrite = 4373 |}] diff --git a/hphp/hack/test/typecheck/array_heterogeneous.php.exp b/hphp/hack/test/typecheck/array_heterogeneous.php.exp index c4a1b699e24..9191edccbce 100644 --- a/hphp/hack/test/typecheck/array_heterogeneous.php.exp +++ b/hphp/hack/test/typecheck/array_heterogeneous.php.exp @@ -1,4 +1,4 @@ File "array_heterogeneous.php", line 20, characters 3-14: -This is not an object of type KeyedContainer, this is an int (Typing[4005]) +This is not an object of type KeyedContainer, this is an int (Typing[4370]) File "array_heterogeneous.php", line 18, characters 16-16: Definition is here diff --git a/hphp/hack/test/typecheck/fake_members11.php.exp b/hphp/hack/test/typecheck/fake_members11.php.exp index 9ab2552c400..1ecc4b11fee 100644 --- a/hphp/hack/test/typecheck/fake_members11.php.exp +++ b/hphp/hack/test/typecheck/fake_members11.php.exp @@ -1,4 +1,4 @@ File "fake_members11.php", line 22, characters 7-23: -This is not an object of type KeyedContainer, this is a nullable type (Typing[4005]) +This is not an object of type KeyedContainer, this is a nullable type (Typing[4370]) File "fake_members11.php", line 13, characters 11-22: Definition is here diff --git a/hphp/hack/test/typecheck/invalid_arraykey/darray_assign_bad.php.exp b/hphp/hack/test/typecheck/invalid_arraykey/darray_assign_bad.php.exp index 10a8fd0121f..b1276c7b610 100644 --- a/hphp/hack/test/typecheck/invalid_arraykey/darray_assign_bad.php.exp +++ b/hphp/hack/test/typecheck/invalid_arraykey/darray_assign_bad.php.exp @@ -1,5 +1,5 @@ File "darray_assign_bad.php", line 9, characters 5-22: -This value is not a valid key type for this container (Typing[4298]) +This value is not a valid key type for this container (Typing[4371]) File "darray_assign_bad.php", line 5, characters 11-28: This container is a darray File "darray_assign_bad.php", line 6, characters 26-32: diff --git a/hphp/hack/test/typecheck/invalid_arraykey/invalid_arraykey.php.exp b/hphp/hack/test/typecheck/invalid_arraykey/invalid_arraykey.php.exp index 0cf34f05cde..d90560ef027 100644 --- a/hphp/hack/test/typecheck/invalid_arraykey/invalid_arraykey.php.exp +++ b/hphp/hack/test/typecheck/invalid_arraykey/invalid_arraykey.php.exp @@ -1,35 +1,35 @@ File "invalid_arraykey.php", line 6, characters 3-14: -This value is not a valid key type for this container (Typing[4298]) +This value is not a valid key type for this container (Typing[4371]) File "invalid_arraykey.php", line 4, characters 8-15: This container is a darray File "invalid_arraykey.php", line 6, characters 6-9: Null cannot be used as a key for a darray File "invalid_arraykey.php", line 7, characters 3-13: -This value is not a valid key type for this container (Typing[4298]) +This value is not a valid key type for this container (Typing[4371]) File "invalid_arraykey.php", line 4, characters 8-15: This container is a darray File "invalid_arraykey.php", line 7, characters 6-8: A float cannot be used as a key for a darray File "invalid_arraykey.php", line 11, characters 3-14: -This value is not a valid key type for this container (Typing[4298]) +This value is not a valid key type for this container (Typing[4371]) File "invalid_arraykey.php", line 9, characters 8-13: This container is an object of type dict File "invalid_arraykey.php", line 11, characters 6-9: Null cannot be used as a key for an object of type dict File "invalid_arraykey.php", line 12, characters 3-13: -This value is not a valid key type for this container (Typing[4298]) +This value is not a valid key type for this container (Typing[4371]) File "invalid_arraykey.php", line 9, characters 8-13: This container is an object of type dict File "invalid_arraykey.php", line 12, characters 6-8: A float cannot be used as a key for an object of type dict File "invalid_arraykey.php", line 16, characters 3-14: -This value is not a valid key type for this container (Typing[4298]) +This value is not a valid key type for this container (Typing[4371]) File "invalid_arraykey.php", line 14, characters 8-12: This container is an object of type Map<[unresolved], [unresolved]> File "invalid_arraykey.php", line 16, characters 6-9: Null cannot be used as a key for an object of type Map<[unresolved], [unresolved]> File "invalid_arraykey.php", line 17, characters 3-13: -This value is not a valid key type for this container (Typing[4298]) +This value is not a valid key type for this container (Typing[4371]) File "invalid_arraykey.php", line 14, characters 8-12: This container is an object of type Map<[unresolved], [unresolved]> File "invalid_arraykey.php", line 17, characters 6-8: diff --git a/hphp/hack/test/typecheck/new_inference/eager_solve/stack_overflow_array.php.like_types.exp b/hphp/hack/test/typecheck/new_inference/eager_solve/stack_overflow_array.php.exp similarity index 93% copy from hphp/hack/test/typecheck/new_inference/eager_solve/stack_overflow_array.php.like_types.exp copy to hphp/hack/test/typecheck/new_inference/eager_solve/stack_overflow_array.php.exp index 32e522a8674..d1a24707230 100644 --- a/hphp/hack/test/typecheck/new_inference/eager_solve/stack_overflow_array.php.like_types.exp +++ b/hphp/hack/test/typecheck/new_inference/eager_solve/stack_overflow_array.php.exp @@ -1,11 +1,11 @@ File "stack_overflow_array.php", line 25, characters 3-13: - ~darray>)>)>)> + darray>)>)>)> File "stack_overflow_array.php", line 15, characters 3-13: This is not an object of type KeyedContainer, this is a bool (Typing[4005]) File "stack_overflow_array.php", line 12, characters 17-21: Definition is here File "stack_overflow_array.php", line 15, characters 3-26: -This is not an object of type KeyedContainer, this is a bool (Typing[4005]) +This is not an object of type KeyedContainer, this is a bool (Typing[4370]) File "stack_overflow_array.php", line 12, characters 17-21: Definition is here File "stack_overflow_array.php", line 16, characters 3-13: @@ -13,7 +13,7 @@ This is not an object of type KeyedContainer, this is a bool (Typing[4005]) File "stack_overflow_array.php", line 12, characters 17-21: Definition is here File "stack_overflow_array.php", line 16, characters 3-30: -This is not an object of type KeyedContainer, this is a bool (Typing[4005]) +This is not an object of type KeyedContainer, this is a bool (Typing[4370]) File "stack_overflow_array.php", line 12, characters 17-21: Definition is here File "stack_overflow_array.php", line 17, characters 3-13: @@ -21,7 +21,7 @@ This is not an object of type KeyedContainer, this is a bool (Typing[4005]) File "stack_overflow_array.php", line 12, characters 17-21: Definition is here File "stack_overflow_array.php", line 17, characters 3-35: -This is not an object of type KeyedContainer, this is a bool (Typing[4005]) +This is not an object of type KeyedContainer, this is a bool (Typing[4370]) File "stack_overflow_array.php", line 12, characters 17-21: Definition is here File "stack_overflow_array.php", line 20, characters 3-13: @@ -29,7 +29,7 @@ This is not an object of type KeyedContainer, this is a bool (Typing[4005]) File "stack_overflow_array.php", line 12, characters 17-21: Definition is here File "stack_overflow_array.php", line 20, characters 3-26: -This is not an object of type KeyedContainer, this is a bool (Typing[4005]) +This is not an object of type KeyedContainer, this is a bool (Typing[4370]) File "stack_overflow_array.php", line 12, characters 17-21: Definition is here File "stack_overflow_array.php", line 21, characters 3-13: @@ -37,7 +37,7 @@ This is not an object of type KeyedContainer, this is a bool (Typing[4005]) File "stack_overflow_array.php", line 12, characters 17-21: Definition is here File "stack_overflow_array.php", line 21, characters 3-30: -This is not an object of type KeyedContainer, this is a bool (Typing[4005]) +This is not an object of type KeyedContainer, this is a bool (Typing[4370]) File "stack_overflow_array.php", line 12, characters 17-21: Definition is here File "stack_overflow_array.php", line 22, characters 3-13: @@ -45,6 +45,6 @@ This is not an object of type KeyedContainer, this is a bool (Typing[4005]) File "stack_overflow_array.php", line 12, characters 17-21: Definition is here File "stack_overflow_array.php", line 22, characters 3-35: -This is not an object of type KeyedContainer, this is a bool (Typing[4005]) +This is not an object of type KeyedContainer, this is a bool (Typing[4370]) File "stack_overflow_array.php", line 12, characters 17-21: Definition is here diff --git a/hphp/hack/test/typecheck/new_inference/eager_solve/stack_overflow_array.php.like_types.exp b/hphp/hack/test/typecheck/new_inference/eager_solve/stack_overflow_array.php.like_types.exp index 32e522a8674..0e8f6667515 100644 --- a/hphp/hack/test/typecheck/new_inference/eager_solve/stack_overflow_array.php.like_types.exp +++ b/hphp/hack/test/typecheck/new_inference/eager_solve/stack_overflow_array.php.like_types.exp @@ -5,7 +5,7 @@ This is not an object of type KeyedContainer, this is a bool (Typing[4005]) File "stack_overflow_array.php", line 12, characters 17-21: Definition is here File "stack_overflow_array.php", line 15, characters 3-26: -This is not an object of type KeyedContainer, this is a bool (Typing[4005]) +This is not an object of type KeyedContainer, this is a bool (Typing[4370]) File "stack_overflow_array.php", line 12, characters 17-21: Definition is here File "stack_overflow_array.php", line 16, characters 3-13: @@ -13,7 +13,7 @@ This is not an object of type KeyedContainer, this is a bool (Typing[4005]) File "stack_overflow_array.php", line 12, characters 17-21: Definition is here File "stack_overflow_array.php", line 16, characters 3-30: -This is not an object of type KeyedContainer, this is a bool (Typing[4005]) +This is not an object of type KeyedContainer, this is a bool (Typing[4370]) File "stack_overflow_array.php", line 12, characters 17-21: Definition is here File "stack_overflow_array.php", line 17, characters 3-13: @@ -21,7 +21,7 @@ This is not an object of type KeyedContainer, this is a bool (Typing[4005]) File "stack_overflow_array.php", line 12, characters 17-21: Definition is here File "stack_overflow_array.php", line 17, characters 3-35: -This is not an object of type KeyedContainer, this is a bool (Typing[4005]) +This is not an object of type KeyedContainer, this is a bool (Typing[4370]) File "stack_overflow_array.php", line 12, characters 17-21: Definition is here File "stack_overflow_array.php", line 20, characters 3-13: @@ -29,7 +29,7 @@ This is not an object of type KeyedContainer, this is a bool (Typing[4005]) File "stack_overflow_array.php", line 12, characters 17-21: Definition is here File "stack_overflow_array.php", line 20, characters 3-26: -This is not an object of type KeyedContainer, this is a bool (Typing[4005]) +This is not an object of type KeyedContainer, this is a bool (Typing[4370]) File "stack_overflow_array.php", line 12, characters 17-21: Definition is here File "stack_overflow_array.php", line 21, characters 3-13: @@ -37,7 +37,7 @@ This is not an object of type KeyedContainer, this is a bool (Typing[4005]) File "stack_overflow_array.php", line 12, characters 17-21: Definition is here File "stack_overflow_array.php", line 21, characters 3-30: -This is not an object of type KeyedContainer, this is a bool (Typing[4005]) +This is not an object of type KeyedContainer, this is a bool (Typing[4370]) File "stack_overflow_array.php", line 12, characters 17-21: Definition is here File "stack_overflow_array.php", line 22, characters 3-13: @@ -45,6 +45,6 @@ This is not an object of type KeyedContainer, this is a bool (Typing[4005]) File "stack_overflow_array.php", line 12, characters 17-21: Definition is here File "stack_overflow_array.php", line 22, characters 3-35: -This is not an object of type KeyedContainer, this is a bool (Typing[4005]) +This is not an object of type KeyedContainer, this is a bool (Typing[4370]) File "stack_overflow_array.php", line 12, characters 17-21: Definition is here diff --git a/hphp/hack/test/typecheck/test_array13.php.exp b/hphp/hack/test/typecheck/test_array13.php.exp index 419fa5ec593..3e26358ecea 100644 --- a/hphp/hack/test/typecheck/test_array13.php.exp +++ b/hphp/hack/test/typecheck/test_array13.php.exp @@ -1,4 +1,4 @@ File "test_array13.php", line 14, characters 3-16: -This is not an object of type KeyedContainer, this is an int (Typing[4005]) +This is not an object of type KeyedContainer, this is an int (Typing[4370]) File "test_array13.php", line 13, characters 43-43: Definition is here diff --git a/hphp/hack/test/unit/utils/errors_test.ml b/hphp/hack/test/unit/utils/errors_test.ml index 9c12a4e56d6..3463d624679 100644 --- a/hphp/hack/test/unit/utils/errors_test.ml +++ b/hphp/hack/test/unit/utils/errors_test.ml @@ -129,20 +129,20 @@ let test_get_sorted_error_list () = let key_pos2 = Pos.make_from (create_path "K2") in let (errors, ()) = Errors.do_with_context file_with_errors Errors.Typing (fun () -> - Errors.invalid_arraykey + Errors.invalid_arraykey_read err_pos (container_pos2, "C2_Type") (key_pos2, "K2_Type"); - Errors.invalid_arraykey + Errors.invalid_arraykey_read err_pos (container_pos1, "C1_Type") (key_pos1, "K1_Type"); error_in "FileWithErrors.php"; - Errors.invalid_arraykey + Errors.invalid_arraykey_read err_pos (container_pos2, "C2_Type") (key_pos2, "K2_Type"); - Errors.invalid_arraykey + Errors.invalid_arraykey_read err_pos (container_pos1, "C1_Type") (key_pos1, "K1_Type"); -- 2.11.4.GIT