From 10ad142d1d67ac0e36b29507664194c0685e20ae Mon Sep 17 00:00:00 2001 From: Vassil Mladenov Date: Fri, 22 Jan 2021 18:35:55 -0800 Subject: [PATCH] Remove Tarray from the typechecker Summary: This removes the `Tarray` type that previously represented `array`, `array`, and `array`. Further, special casing of `array_map` is removed in this diff. Reviewed By: Wilfred Differential Revision: D24370672 fbshipit-source-id: 39df94a421447c25fc08deb518153bdd5486ba72 --- hphp/hack/src/decl/decl_instantiate.ml | 4 - hphp/hack/src/decl/decl_pos_utils.ml | 1 - .../oxidized_by_ref/decl_visitor/node_impl_gen.rs | 3 +- .../src/oxidized_by_ref/gen/typing_defs_core.rs | 11 +-- .../manual/typing_defs_core_impl.rs | 1 - hphp/hack/src/typing/type_visitor.ml | 13 +--- hphp/hack/src/typing/typing_defs.ml | 4 - hphp/hack/src/typing/typing_defs_core.ml | 26 ------- hphp/hack/src/typing/typing_defs_core.mli | 7 -- hphp/hack/src/typing/typing_enforceability.ml | 2 - hphp/hack/src/typing/typing_enforceable_hint.ml | 12 ++- hphp/hack/src/typing/typing_generic.ml | 3 - hphp/hack/src/typing/typing_kinding.ml | 8 -- hphp/hack/src/typing/typing_phase.ml | 22 ------ hphp/hack/src/typing/typing_print.ml | 8 -- hphp/hack/src/typing/typing_reified_check.ml | 4 +- hphp/hack/src/typing/typing_special_fun.ml | 87 +--------------------- hphp/hack/src/typing/typing_utils.ml | 1 - hphp/hack/src/typing/typing_variance.ml | 20 +---- .../array_map_explicitly_typed_error.php | 11 --- .../array_map_explicitly_typed_error.php.exp | 49 ------------ hphp/hack/test/tast/array_map.php.exp | 33 +++----- ...h_array_map_does_not_return_vect_like_array.php | 5 -- ...ray_map_does_not_return_vect_like_array.php.exp | 12 --- ...rray_with_array_map_returns_dict_like_array.php | 5 -- ..._with_array_map_returns_dict_like_array.php.exp | 1 - ..._map_returns_dict_like_array.php.like_types.exp | 6 -- ...h_array_map_does_not_return_dict_like_array.php | 5 -- ...ray_map_does_not_return_dict_like_array.php.exp | 6 -- .../test/typecheck/array_map_filter/array_map.php | 10 --- .../typecheck/array_map_filter/array_map.php.exp | 1 - .../test/typecheck/array_map_filter/array_map1.php | 5 -- .../typecheck/array_map_filter/array_map1.php.exp | 4 - .../typecheck/array_map_filter/array_map10.php | 5 -- .../typecheck/array_map_filter/array_map10.php.exp | 12 --- .../test/typecheck/array_map_filter/array_map2.php | 9 --- .../typecheck/array_map_filter/array_map2.php.exp | 6 -- .../test/typecheck/array_map_filter/array_map3.php | 11 --- .../typecheck/array_map_filter/array_map3.php.exp | 6 -- .../test/typecheck/array_map_filter/array_map4.php | 5 -- .../typecheck/array_map_filter/array_map4.php.exp | 6 -- .../test/typecheck/array_map_filter/array_map5.php | 5 -- .../typecheck/array_map_filter/array_map5.php.exp | 6 -- .../test/typecheck/array_map_filter/array_map7.php | 37 --------- .../typecheck/array_map_filter/array_map7.php.exp | 14 ---- .../array_map_filter/array_map7.php.like_types.exp | 38 ---------- .../test/typecheck/array_map_filter/array_map9.php | 5 -- .../typecheck/array_map_filter/array_map9.php.exp | 1 - .../array_map_explicitly_typed.php | 7 -- .../array_map_explicitly_typed.php.exp | 1 - .../array_map_explicitly_typed_arity.php | 7 -- .../array_map_explicitly_typed_arity.php.exp | 4 - .../array_map_explicitly_typed_error.php | 11 --- .../array_map_explicitly_typed_error.php.exp | 22 ------ hphp/hack/test/typecheck/deprecated_fun_id.php | 8 -- hphp/hack/test/typecheck/deprecated_fun_id.php.exp | 10 --- hphp/hack/test/typecheck/unused_awaitable16.php | 10 --- .../hack/test/typecheck/unused_awaitable16.php.exp | 4 - hphp/hack/test/typecheck/void_usage_5.php | 16 ---- hphp/hack/test/typecheck/void_usage_5.php.exp | 10 --- 60 files changed, 34 insertions(+), 632 deletions(-) delete mode 100644 hphp/hack/test/error_formatting_highlighted/array_map_explicitly_typed_error.php delete mode 100644 hphp/hack/test/error_formatting_highlighted/array_map_explicitly_typed_error.php.exp delete mode 100644 hphp/hack/test/typecheck/array/safe_vector_array/darray_with_array_map_does_not_return_vect_like_array.php delete mode 100644 hphp/hack/test/typecheck/array/safe_vector_array/darray_with_array_map_does_not_return_vect_like_array.php.exp delete mode 100644 hphp/hack/test/typecheck/array/safe_vector_array/darray_with_array_map_returns_dict_like_array.php delete mode 100644 hphp/hack/test/typecheck/array/safe_vector_array/darray_with_array_map_returns_dict_like_array.php.exp delete mode 100644 hphp/hack/test/typecheck/array/safe_vector_array/darray_with_array_map_returns_dict_like_array.php.like_types.exp delete mode 100644 hphp/hack/test/typecheck/array/safe_vector_array/varray_with_array_map_does_not_return_dict_like_array.php delete mode 100644 hphp/hack/test/typecheck/array/safe_vector_array/varray_with_array_map_does_not_return_dict_like_array.php.exp delete mode 100644 hphp/hack/test/typecheck/array_map_filter/array_map.php delete mode 100644 hphp/hack/test/typecheck/array_map_filter/array_map.php.exp delete mode 100644 hphp/hack/test/typecheck/array_map_filter/array_map1.php delete mode 100644 hphp/hack/test/typecheck/array_map_filter/array_map1.php.exp delete mode 100644 hphp/hack/test/typecheck/array_map_filter/array_map10.php delete mode 100644 hphp/hack/test/typecheck/array_map_filter/array_map10.php.exp delete mode 100644 hphp/hack/test/typecheck/array_map_filter/array_map2.php delete mode 100644 hphp/hack/test/typecheck/array_map_filter/array_map2.php.exp delete mode 100644 hphp/hack/test/typecheck/array_map_filter/array_map3.php delete mode 100644 hphp/hack/test/typecheck/array_map_filter/array_map3.php.exp delete mode 100644 hphp/hack/test/typecheck/array_map_filter/array_map4.php delete mode 100644 hphp/hack/test/typecheck/array_map_filter/array_map4.php.exp delete mode 100644 hphp/hack/test/typecheck/array_map_filter/array_map5.php delete mode 100644 hphp/hack/test/typecheck/array_map_filter/array_map5.php.exp delete mode 100644 hphp/hack/test/typecheck/array_map_filter/array_map7.php delete mode 100644 hphp/hack/test/typecheck/array_map_filter/array_map7.php.exp delete mode 100644 hphp/hack/test/typecheck/array_map_filter/array_map7.php.like_types.exp delete mode 100644 hphp/hack/test/typecheck/array_map_filter/array_map9.php delete mode 100644 hphp/hack/test/typecheck/array_map_filter/array_map9.php.exp delete mode 100644 hphp/hack/test/typecheck/array_map_filter/array_map_explicitly_typed.php delete mode 100644 hphp/hack/test/typecheck/array_map_filter/array_map_explicitly_typed.php.exp delete mode 100644 hphp/hack/test/typecheck/array_map_filter/array_map_explicitly_typed_arity.php delete mode 100644 hphp/hack/test/typecheck/array_map_filter/array_map_explicitly_typed_arity.php.exp delete mode 100644 hphp/hack/test/typecheck/array_map_filter/array_map_explicitly_typed_error.php delete mode 100644 hphp/hack/test/typecheck/array_map_filter/array_map_explicitly_typed_error.php.exp delete mode 100644 hphp/hack/test/typecheck/deprecated_fun_id.php delete mode 100644 hphp/hack/test/typecheck/deprecated_fun_id.php.exp delete mode 100644 hphp/hack/test/typecheck/unused_awaitable16.php delete mode 100644 hphp/hack/test/typecheck/unused_awaitable16.php.exp delete mode 100644 hphp/hack/test/typecheck/void_usage_5.php delete mode 100644 hphp/hack/test/typecheck/void_usage_5.php.exp diff --git a/hphp/hack/src/decl/decl_instantiate.ml b/hphp/hack/src/decl/decl_instantiate.ml index 785cd346b75..e5ed25f4ad3 100644 --- a/hphp/hack/src/decl/decl_instantiate.ml +++ b/hphp/hack/src/decl/decl_instantiate.ml @@ -62,10 +62,6 @@ and instantiate_ subst x = | Taccess (ty, id) -> let ty = instantiate subst ty in Taccess (ty, id) - | Tarray (ty1, ty2) -> - let ty1 = Option.map ty1 (instantiate subst) in - let ty2 = Option.map ty2 (instantiate subst) in - Tarray (ty1, ty2) | Tdarray (ty1, ty2) -> Tdarray (instantiate subst ty1, instantiate subst ty2) | Tvarray ty -> Tvarray (instantiate subst ty) | Tvarray_or_darray (ty1, ty2) -> diff --git a/hphp/hack/src/decl/decl_pos_utils.ml b/hphp/hack/src/decl/decl_pos_utils.ml index f0bfa1bea9e..a614c0f0f62 100644 --- a/hphp/hack/src/decl/decl_pos_utils.ml +++ b/hphp/hack/src/decl/decl_pos_utils.ml @@ -117,7 +117,6 @@ struct and ty_ : decl_phase ty_ -> decl_phase ty_ = function | (Tany _ | Tthis | Terr | Tmixed | Tnonnull | Tdynamic | Tvar _) as x -> x - | Tarray (ty1, ty2) -> Tarray (ty_opt ty1, ty_opt ty2) | Tdarray (ty1, ty2) -> Tdarray (ty ty1, ty ty2) | Tvarray root_ty -> Tvarray (ty root_ty) | Tvarray_or_darray (ty1, ty2) -> Tvarray_or_darray (ty ty1, ty ty2) diff --git a/hphp/hack/src/oxidized_by_ref/decl_visitor/node_impl_gen.rs b/hphp/hack/src/oxidized_by_ref/decl_visitor/node_impl_gen.rs index 80950e4da3d..0beb7d96c62 100644 --- a/hphp/hack/src/oxidized_by_ref/decl_visitor/node_impl_gen.rs +++ b/hphp/hack/src/oxidized_by_ref/decl_visitor/node_impl_gen.rs @@ -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<<734635ed3f7bdf5a009a63f66686f299>> +// @generated SignedSource<> // // To regenerate this file, run: // hphp/hack/src/oxidize_regen.sh @@ -924,7 +924,6 @@ impl<'a> Node<'a> for Ty_<'a> { match self { Ty_::Tthis => {} Ty_::Tapply(ref __binding_0) => __binding_0.accept(v), - Ty_::Tarray(ref __binding_0) => __binding_0.accept(v), Ty_::Tmixed => {} Ty_::Tlike(ref __binding_0) => __binding_0.accept(v), Ty_::Tany(ref __binding_0) => __binding_0.accept(v), diff --git a/hphp/hack/src/oxidized_by_ref/gen/typing_defs_core.rs b/hphp/hack/src/oxidized_by_ref/gen/typing_defs_core.rs index d12d2c44ae3..b2260c664a2 100644 --- a/hphp/hack/src/oxidized_by_ref/gen/typing_defs_core.rs +++ b/hphp/hack/src/oxidized_by_ref/gen/typing_defs_core.rs @@ -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<<495e92f107571ba0201dac80f1d7393d>> +// @generated SignedSource<> // // To regenerate this file, run: // hphp/hack/src/oxidize_regen.sh @@ -399,15 +399,6 @@ pub enum Ty_<'a> { Tthis, /// Either an object type or a type alias, ty list are the arguments Tapply(&'a (nast::Sid<'a>, &'a [&'a Ty<'a>])), - /// The type of the various forms of "array": - /// - /// ``` - /// Tarray (None, None) => "array" - /// Tarray (Some ty, None) => "array" - /// Tarray (Some ty1, Some ty2) => "array" - /// Tarray (None, Some ty) => [invalid] - /// ``` - Tarray(&'a (Option<&'a Ty<'a>>, Option<&'a Ty<'a>>)), /// "Any" is the type of a variable with a missing annotation, and "mixed" is /// the type of a variable annotated as "mixed". THESE TWO ARE VERY DIFFERENT! /// Any unifies with anything, i.e., it is both a supertype and subtype of any diff --git a/hphp/hack/src/oxidized_by_ref/manual/typing_defs_core_impl.rs b/hphp/hack/src/oxidized_by_ref/manual/typing_defs_core_impl.rs index 78bc5f765ca..dabe51ac2d4 100644 --- a/hphp/hack/src/oxidized_by_ref/manual/typing_defs_core_impl.rs +++ b/hphp/hack/src/oxidized_by_ref/manual/typing_defs_core_impl.rs @@ -120,7 +120,6 @@ impl std::fmt::Debug for Ty_<'_> { Tthis => write!(f, "Tthis"), Tapply((id, tys)) => f.debug_tuple("Tapply").field(id).field(tys).finish(), Taccess(taccess) => f.debug_tuple("Taccess").field(taccess).finish(), - Tarray((tk, tv)) => f.debug_tuple("Tarray").field(tk).field(tv).finish(), Tmixed => write!(f, "Tmixed"), Tlike(ty) => f.debug_tuple("Tlike").field(ty).finish(), Tany(_) => write!(f, "Tany"), diff --git a/hphp/hack/src/typing/type_visitor.ml b/hphp/hack/src/typing/type_visitor.ml index e6f6028e97b..cd528988789 100644 --- a/hphp/hack/src/typing/type_visitor.ml +++ b/hphp/hack/src/typing/type_visitor.ml @@ -25,8 +25,6 @@ class type ['a] decl_type_visitor_type = method on_tthis : 'a -> Reason.t -> 'a - method on_tarray : 'a -> Reason.t -> decl_ty option -> decl_ty option -> 'a - method on_tvarray_or_darray : 'a -> Reason.t -> decl_ty -> decl_ty -> 'a method on_tvarray : 'a -> Reason.t -> decl_ty -> 'a @@ -79,11 +77,6 @@ class virtual ['a] decl_type_visitor : ['a] decl_type_visitor_type = method on_tthis acc _ = acc - method on_tarray acc _ ty1_opt ty2_opt = - let acc = Option.fold ~f:this#on_type ~init:acc ty1_opt in - let acc = Option.fold ~f:this#on_type ~init:acc ty2_opt in - acc - method on_tvarray_or_darray acc _ ty1 ty2 = let acc = this#on_type acc ty1 in this#on_type acc ty2 @@ -147,10 +140,8 @@ class virtual ['a] decl_type_visitor : ['a] decl_type_visitor_type = | Tnonnull -> this#on_tnonnull acc r | Tdynamic -> this#on_tdynamic acc r | Tthis -> this#on_tthis acc r - | Tarray (ty1_opt, ty2_opt) -> this#on_tarray acc r ty1_opt ty2_opt - | Tdarray (ty1, ty2) -> - this#on_type acc (mk (r, Tarray (Some ty1, Some ty2))) - | Tvarray ty -> this#on_type acc (mk (r, Tarray (Some ty, None))) + | Tdarray (ty1, ty2) -> this#on_tdarray acc r ty1 ty2 + | Tvarray ty -> this#on_tvarray acc r ty | Tvarray_or_darray (ty1, ty2) -> this#on_tvarray_or_darray acc r ty1 ty2 | Tgeneric (s, args) -> this#on_tgeneric acc r s args | Toption ty -> this#on_toption acc r ty diff --git a/hphp/hack/src/typing/typing_defs.ml b/hphp/hack/src/typing/typing_defs.ml index ff22c487616..a4ddea14d55 100644 --- a/hphp/hack/src/typing/typing_defs.ml +++ b/hphp/hack/src/typing/typing_defs.ml @@ -436,7 +436,6 @@ let decl_ty_con_ordinal ty_ = | Tapply _ -> 2 | Tgeneric _ -> 3 | Taccess _ -> 4 - | Tarray _ -> 5 | Tdarray _ -> 6 | Tvarray _ -> 7 | Tvarray_or_darray _ -> 8 @@ -939,8 +938,6 @@ let rec equal_decl_ty_ ty_1 ty_2 = String.equal s1 s2 && equal_decl_tyl argl1 argl2 | (Taccess (ty1, (_, s1)), Taccess (ty2, (_, s2))) -> equal_decl_ty ty1 ty2 && String.equal s1 s2 - | (Tarray (tk1, tv1), Tarray (tk2, tv2)) -> - Option.equal equal_decl_ty tk1 tk2 && Option.equal equal_decl_ty tv1 tv2 | (Tdarray (tk1, tv1), Tdarray (tk2, tv2)) -> equal_decl_ty tk1 tk2 && equal_decl_ty tv1 tv2 | (Tvarray ty1, Tvarray ty2) -> equal_decl_ty ty1 ty2 @@ -968,7 +965,6 @@ let rec equal_decl_ty_ ty_1 ty_2 = | (Tapply _, _) | (Tgeneric _, _) | (Taccess _, _) - | (Tarray _, _) | (Tdarray _, _) | (Tvarray _, _) | (Tvarray_or_darray _, _) diff --git a/hphp/hack/src/typing/typing_defs_core.ml b/hphp/hack/src/typing/typing_defs_core.ml index 43f2b89b224..fe6f1170148 100644 --- a/hphp/hack/src/typing/typing_defs_core.ml +++ b/hphp/hack/src/typing/typing_defs_core.ml @@ -171,16 +171,6 @@ and _ ty_ = | Tthis : decl_phase ty_ (** The late static bound type of a class *) | Tapply : Nast.sid * decl_ty list -> decl_phase ty_ (** Either an object type or a type alias, ty list are the arguments *) - | Tarray : decl_ty option * decl_ty option -> decl_phase ty_ - (** The type of the various forms of "array": - * - * ``` - * Tarray (None, None) => "array" - * Tarray (Some ty, None) => "array" - * Tarray (Some ty1, Some ty2) => "array" - * Tarray (None, Some ty) => [invalid] - * ``` - *) | Tmixed : decl_phase ty_ (** "Any" is the type of a variable with a missing annotation, and "mixed" is * the type of a variable annotated as "mixed". THESE TWO ARE VERY DIFFERENT! @@ -576,22 +566,6 @@ module Pp = struct Format.fprintf fmt "(@[<2>Taccess@ "; pp_taccess_type fmt a0; Format.fprintf fmt "@])" - | Tarray (a0, a1) -> - Format.fprintf fmt "(@[<2>Tarray (@,"; - (match a0 with - | None -> Format.pp_print_string fmt "None" - | Some x -> - Format.pp_print_string fmt "(Some "; - pp_ty fmt x; - Format.pp_print_string fmt ")"); - Format.fprintf fmt ",@ "; - (match a1 with - | None -> Format.pp_print_string fmt "None" - | Some x -> - Format.pp_print_string fmt "(Some "; - pp_ty fmt x; - Format.pp_print_string fmt ")"); - Format.fprintf fmt "@,))@]" | Tdarray (a0, a1) -> Format.fprintf fmt "(@[<2>Tdarray (@,"; pp_ty fmt a0; diff --git a/hphp/hack/src/typing/typing_defs_core.mli b/hphp/hack/src/typing/typing_defs_core.mli index e55b58d0898..a1e9c0d46c7 100644 --- a/hphp/hack/src/typing/typing_defs_core.mli +++ b/hphp/hack/src/typing/typing_defs_core.mli @@ -169,13 +169,6 @@ and _ ty_ = | Tthis : decl_phase ty_ (* Either an object type or a type alias, ty list are the arguments *) | Tapply : Nast.sid * decl_ty list -> decl_phase ty_ - (* The type of the various forms of "array": - * Tarray (None, None) => "array" - * Tarray (Some ty, None) => "array" - * Tarray (Some ty1, Some ty2) => "array" - * Tarray (None, Some ty) => [invalid] - *) - | Tarray : decl_ty option * decl_ty option -> decl_phase ty_ (* "Any" is the type of a variable with a missing annotation, and "mixed" is * the type of a variable annotated as "mixed". THESE TWO ARE VERY DIFFERENT! * Any unifies with anything, i.e., it is both a supertype and subtype of any diff --git a/hphp/hack/src/typing/typing_enforceability.ml b/hphp/hack/src/typing/typing_enforceability.ml index 4a052325787..aae8fb1099a 100644 --- a/hphp/hack/src/typing/typing_enforceability.ml +++ b/hphp/hack/src/typing/typing_enforceability.ml @@ -84,8 +84,6 @@ let is_enforceable (env : env) (ty : decl_ty) = false | Taccess _ -> false | Tlike _ -> false - | Tarray (None, None) -> true - | Tarray _ -> false | Tprim prim -> begin match prim with diff --git a/hphp/hack/src/typing/typing_enforceable_hint.ml b/hphp/hack/src/typing/typing_enforceable_hint.ml index cb6cee14c0c..4cc67ca2adf 100644 --- a/hphp/hack/src/typing/typing_enforceable_hint.ml +++ b/hphp/hack/src/typing/typing_enforceable_hint.ml @@ -132,10 +132,16 @@ let validator = r "a type with generics, because generics are erased at runtime" - method! on_tarray acc r tk_opt tv_opt = + method! on_tvarray acc r tk = if acc.like_context then - let acc = Option.fold ~f:this#on_type ~init:acc tk_opt in - Option.fold ~f:this#on_type ~init:acc tv_opt + this#on_type acc tk + else + this#invalid acc r "an array type" + + method! on_tdarray acc r tk tv = + if acc.like_context then + let acc = this#on_type acc tk in + this#on_type acc tv else this#invalid acc r "an array type" diff --git a/hphp/hack/src/typing/typing_generic.ml b/hphp/hack/src/typing/typing_generic.ml index 46917b171d0..d5f1dd7c1bd 100644 --- a/hphp/hack/src/typing/typing_generic.ml +++ b/hphp/hack/src/typing/typing_generic.ml @@ -48,9 +48,6 @@ end = struct List.iter tyl ty | Tapply (_, tyl) -> List.iter tyl ty | Taccess (t, _) -> ty t - | Tarray (t1, t2) -> - Option.iter ~f:ty t1; - Option.iter ~f:ty t2 | Tdarray (t1, t2) | Tvarray_or_darray (t1, t2) -> ty t1; diff --git a/hphp/hack/src/typing/typing_kinding.ml b/hphp/hack/src/typing/typing_kinding.ml index 7db1c216d98..603ca267410 100644 --- a/hphp/hack/src/typing/typing_kinding.ml +++ b/hphp/hack/src/typing/typing_kinding.ml @@ -323,11 +323,6 @@ module Simple = struct check_well_kinded_type ~allow_missing_targs:false env enf_ty.et_type and check_well_kinded_type ~allow_missing_targs env (ty : decl_ty) = - let check_opt = - Option.value_map - ~default:() - ~f:(check_well_kinded_type ~allow_missing_targs:false env) - in let (r, ty_) = deref ty in let use_pos = Reason.to_pos r in let check = check_well_kinded_type ~allow_missing_targs:false env in @@ -353,9 +348,6 @@ module Simple = struct | Tmixed | Tthis -> () - | Tarray (ty1, ty2) -> - check_opt ty1; - check_opt ty2 | Tdarray (tk, tv) -> check tk; check tv diff --git a/hphp/hack/src/typing/typing_phase.ml b/hphp/hack/src/typing/typing_phase.ml index 20cbc9d532a..ea9cd1f2bb6 100644 --- a/hphp/hack/src/typing/typing_phase.ml +++ b/hphp/hack/src/typing/typing_phase.ml @@ -142,28 +142,6 @@ let rec localize ~ety_env env (dty : decl_ty) = | reason -> Reason.Rinstantiate (reason, SN.Typehints.this, r)) in (env, ty) - | (r, Tarray (ty1, ty2)) -> - let (env, ty) = - match (ty1, ty2) with - | (None, None) -> - let tk = MakeType.arraykey Reason.(Rvarray_or_darray_key (to_pos r)) in - let (env, tv) = - if GlobalOptions.tco_global_inference env.genv.tcopt then - Env.new_global_tyvar env r - else - (env, mk (r, TUtils.tany env)) - in - (env, Tvarray_or_darray (tk, tv)) - | (Some tv, None) -> - let (env, tv) = tvar_or_localize ~ety_env env r tv ~i:1 in - (env, Tvarray tv) - | (Some tk, Some tv) -> - let (env, tk) = tvar_or_localize ~ety_env env r tk ~i:0 in - let (env, tv) = tvar_or_localize ~ety_env env r tv ~i:1 in - (env, Tdarray (tk, tv)) - | (None, Some _) -> failwith "Invalid array declaration type" - in - (env, mk (r, ty)) | (r, Tdarray (tk, tv)) -> let (env, tk) = tvar_or_localize ~ety_env env r tk ~i:0 in let (env, tv) = tvar_or_localize ~ety_env env r tv ~i:1 in diff --git a/hphp/hack/src/typing/typing_print.ml b/hphp/hack/src/typing/typing_print.ml index dbed4fae993..9ae8486af01 100644 --- a/hphp/hack/src/typing/typing_print.ml +++ b/hphp/hack/src/typing/typing_print.ml @@ -219,13 +219,6 @@ module Full = struct let tvarray_or_darray k x y = list "varray_or_darray<" k [x; y] ">" - let tarray k x y = - match (x, y) with - | (None, None) -> text "array" - | (Some x, None) -> list "array<" k [x] ">" - | (Some x, Some y) -> list "array<" k [x; y] ">" - | (None, Some _) -> assert false - let tfun ~ty to_doc st env ft = Concat [ @@ -330,7 +323,6 @@ module Full = struct | Tdarray (x, y) -> tdarray k x y | Tvarray x -> tvarray k x | Tvarray_or_darray (x, y) -> tvarray_or_darray k x y - | Tarray (x, y) -> tarray k x y | Tapply ((_, s), []) -> to_doc s | Tgeneric (s, []) -> to_doc s | Taccess (root_ty, id) -> Concat [k root_ty; text "::"; to_doc (snd id)] diff --git a/hphp/hack/src/typing/typing_reified_check.ml b/hphp/hack/src/typing/typing_reified_check.ml index 3f7202222de..c3a3fca3869 100644 --- a/hphp/hack/src/typing/typing_reified_check.ml +++ b/hphp/hack/src/typing/typing_reified_check.ml @@ -42,7 +42,9 @@ let validator = | Nast.SoftReified -> this#invalid acc r "soft reified" | Nast.Reified -> acc - method! on_tarray acc r _ _ = this#invalid acc r "an array type" + method! on_tvarray acc r _ = this#invalid acc r "an array type" + + method! on_tdarray acc r _ _ = this#invalid acc r "an array type" method! on_tvarray_or_darray acc r _ _ = this#invalid acc r "an array type" diff --git a/hphp/hack/src/typing/typing_special_fun.ml b/hphp/hack/src/typing/typing_special_fun.ml index 4e4f2938047..2ddf70748a2 100644 --- a/hphp/hack/src/typing/typing_special_fun.ml +++ b/hphp/hack/src/typing/typing_special_fun.ml @@ -11,13 +11,11 @@ open Hh_prelude open Typing_defs module SN = Naming_special_names module MakeType = Typing_make_type -module TUtils = Typing_utils let update_param p ty = { p with fp_type = { p.fp_type with et_type = ty } } -(* Given a decl function type that was obtained from an hhi file, - * transform it for special functions such as `idx` and `array_map` - * according to the number of arguments actually passed to the function +(* Transform the special function `idx` according to the number + * of arguments actually passed to the function *) let transform_special_fun_ty fty id nargs = (* The idx function has two signatures, depending on number of arguments @@ -75,86 +73,5 @@ let transform_special_fun_ty fty id nargs = | _ -> (fty.ft_params, fty.ft_ret.et_type) in { fty with ft_params = params; ft_ret = { fty.ft_ret with et_type = ret } } - else if - (* - Builds a function with signature: - - function( - (function(T1, ..., Tn):Tr), - Container, - ..., - Container, - ): array - - where n is one fewer than the actual number of arguments. The hhi - file just has the untyped declaration - - function array_map($callback, $arr1, ...$args); - *) - String.equal (snd id) SN.StdlibFunctions.array_map && nargs > 0 - then - let arity = nargs - 1 in - if Int.equal arity 0 then - fty - else - let (param1, param2) = - match fty.ft_params with - | param1 :: param2 :: _ -> (param1, param2) - | _ -> assert false - in - let r1 = get_reason param1.fp_type.et_type in - let r2 = get_reason param2.fp_type.et_type in - let rret = get_reason fty.ft_ret.et_type in - let tr = MakeType.generic rret "Tr" in - let rec make_tparam_names i = - if Int.equal i 0 then - [] - else - ("T" ^ string_of_int i) :: make_tparam_names (i - 1) - in - let tparam_names = List.rev (make_tparam_names arity) in - let vars = List.map tparam_names (fun n -> MakeType.generic r2 n) in - let make_tparam name = - { - tp_variance = Ast_defs.Invariant; - tp_name = (fst id, name); - tp_tparams = []; - tp_constraints = []; - tp_reified = Aast.Erased; - tp_user_attributes = []; - } - in - let ft_tparams = List.map tparam_names make_tparam @ [make_tparam "Tr"] in - (* Construct type of first parameter *) - let param1 = - update_param - param1 - (mk - ( r1, - Tfun - { - ft_arity = Fstandard; - ft_tparams = []; - ft_where_constraints = []; - ft_params = List.map vars TUtils.default_fun_param; - ft_ret = MakeType.unenforced tr; - ft_implicit_params = { capability = CapDefaults (fst id) }; - ft_flags = fty.ft_flags; - ft_reactive = fty.ft_reactive; - ft_ifc_decl = fty.ft_ifc_decl; - } )) - in - let param_rest = - List.map vars (fun var -> - let tc = Tapply ((fst id, SN.Collections.cContainer), [var]) in - TUtils.default_fun_param (mk (r2, tc))) - in - { - fty with - ft_arity = Fstandard; - ft_params = param1 :: param_rest; - ft_tparams; - ft_ret = MakeType.unenforced (mk (rret, Tarray (Some tr, None))); - } else fty diff --git a/hphp/hack/src/typing/typing_utils.ml b/hphp/hack/src/typing/typing_utils.ml index 2bb3244a0e0..986acc36dcb 100644 --- a/hphp/hack/src/typing/typing_utils.ml +++ b/hphp/hack/src/typing/typing_utils.ml @@ -542,7 +542,6 @@ let unwrap_class_type ty = | (r, Tapply (name, tparaml)) -> (r, name, tparaml) | ( _, ( Terr | Tdynamic | Tany _ | Tmixed | Tnonnull - | Tarray (_, _) | Tdarray (_, _) | Tvarray _ | Tvarray_or_darray _ | Tgeneric _ | Toption _ | Tlike _ | Tprim _ | Tfun _ | Ttuple _ | Tshape _ | Tunion _ | Tintersection _ diff --git a/hphp/hack/src/typing/typing_variance.ml b/hphp/hack/src/typing/typing_variance.ml index 645ec673317..357de40decd 100644 --- a/hphp/hack/src/typing/typing_variance.ml +++ b/hphp/hack/src/typing/typing_variance.ml @@ -400,10 +400,6 @@ and fun_ret tenv root variance env ty = in type_ tenv root variance env ty -and type_option tenv root variance env = function - | None -> () - | Some ty -> type_ tenv root variance env ty - and type_list tenv root variance env tyl = List.iter tyl ~f:(type_ tenv root variance env) @@ -441,15 +437,11 @@ and type_ tenv root variance env ty = | Tdynamic | Tvar _ -> () - | Tarray (ty1, ty2) -> - type_option tenv root variance env ty1; - type_option tenv root variance env ty2 - | Tdarray (ty1, ty2) -> - type_ tenv root variance env (mk (reason, Tarray (Some ty1, Some ty2))) - | Tvarray ty -> - type_ tenv root variance env (mk (reason, Tarray (Some ty, None))) + | Tdarray (ty1, ty2) | Tvarray_or_darray (ty1, ty2) -> - type_ tenv root variance env (mk (reason, Tarray (Some ty1, Some ty2))) + type_ tenv root variance env ty1; + type_ tenv root variance env ty2 + | Tvarray ty -> type_ tenv root variance env ty | Tthis -> (* Check that 'this' isn't being improperly referenced in a contravariant * position. @@ -617,9 +609,6 @@ and get_typarams tenv root env (ty : decl_ty) = let flip (pos, neg) = (neg, pos) in let single id pos = (SMap.singleton id [pos], SMap.empty) in let get_typarams_union acc ty = union acc (get_typarams tenv root env ty) in - let get_typarams_opt ty_opt = - Option.value_map ty_opt ~f:(get_typarams tenv root env) ~default:empty - in match get_node ty with | Tgeneric (id, _tyargs) -> (* TODO(T69551141) handle type arguments *) @@ -824,7 +813,6 @@ and get_typarams tenv root env (ty : decl_ty) = in let variancel = get_class_variance tenv pos_name in get_typarams_variance_list empty variancel tyl - | Tarray (ty1, ty2) -> union (get_typarams_opt ty1) (get_typarams_opt ty2) | Tdarray (ty1, ty2) -> union (get_typarams tenv root env ty1) (get_typarams tenv root env ty2) | Tvarray ty -> get_typarams tenv root env ty diff --git a/hphp/hack/test/error_formatting_highlighted/array_map_explicitly_typed_error.php b/hphp/hack/test/error_formatting_highlighted/array_map_explicitly_typed_error.php deleted file mode 100644 index dc6b5df3b8c..00000000000 --- a/hphp/hack/test/error_formatting_highlighted/array_map_explicitly_typed_error.php +++ /dev/null @@ -1,11 +0,0 @@ -( - function($x, $y) { - return $x + $y; }, - vec[1, 2], - vec[2,3]); - return $x[0]; -} diff --git a/hphp/hack/test/error_formatting_highlighted/array_map_explicitly_typed_error.php.exp b/hphp/hack/test/error_formatting_highlighted/array_map_explicitly_typed_error.php.exp deleted file mode 100644 index fea47e6c8f7..00000000000 --- a/hphp/hack/test/error_formatting_highlighted/array_map_explicitly_typed_error.php.exp +++ /dev/null @@ -1,49 +0,0 @@ -Typing[4110] Typing error [1] --> Expected num because this is used in an arithmetic operation [2] --> But got string because the type of the lambda parameter could not be determined. Please add a type hint to the parameter [3] - -array_map_explicitly_typed_error.php:7:14 - 4 | function f(): int { - 5 | $x = array_map( -[3] 6 | function($x, $y) { -[1,2] 7 | return $x + $y; }, - 8 | vec[1, 2], - 9 | vec[2,3]); - -Typing[4110] Some elements in this collection are incompatible [1] --> Expected string [2] --> via this generic T1 [3] --> But got int [4] - -array_map_explicitly_typed_error.php:8:5 - 3 | - 4 | function f(): int { -[2] 5 | $x = array_map( - 6 | function($x, $y) { - 7 | return $x + $y; }, -[1,4] 8 | vec[1, 2], - 9 | vec[2,3]); - 10 | return $x[0]; - -stdlib/builtins_array.hhi:121:31 -[3] 121 | No source found - -Typing[4110] Some elements in this collection are incompatible [1] --> Expected string [2] --> via this generic T1 [3] --> But got int [4] - -array_map_explicitly_typed_error.php:8:5 - 3 | - 4 | function f(): int { -[2] 5 | $x = array_map( - 6 | function($x, $y) { - 7 | return $x + $y; }, -[1,4] 8 | vec[1, 2], - 9 | vec[2,3]); - 10 | return $x[0]; - -stdlib/builtins_array.hhi:121:31 -[3] 121 | No source found - -3 errors found. diff --git a/hphp/hack/test/tast/array_map.php.exp b/hphp/hack/test/tast/array_map.php.exp index 7021e52eddb..59d8fee5af5 100644 --- a/hphp/hack/test/tast/array_map.php.exp +++ b/hphp/hack/test/tast/array_map.php.exp @@ -124,25 +124,22 @@ ))))); ([15:3-22], (Expr - (([15:3-21], darray), + (([15:3-21], darray), (Call ( - (([15:3-12], (function((function(int): bool) $callback, Container): darray)), + (([15:3-12], (function($callback, $arr1, ...): darray)), (Id ([15:3-12], "\\array_map"))), - [((int), ([15:3-12], (Happly (([Pos.none], "_"), [])))); - ((bool), ([15:3-12], (Happly (([Pos.none], "_"), []))))], + [], [(([15:13-15], (function(int): bool)), (Lvar ([15:13-15], $f))); (([15:17-20], Container), (Lvar ([15:17-20], $ci)))], None))))); ([16:3-27], (Expr - (([16:3-26], varray), + (([16:3-26], _), (Call ( - (([16:3-12], (function((function(int, string): bool) $callback, Container, Container): varray)), + (([16:3-12], (function($callback, $arr1, ...): _)), (Id ([16:3-12], "\\array_map"))), - [((int), ([16:3-12], (Happly (([Pos.none], "_"), [])))); - ((string), ([16:3-12], (Happly (([Pos.none], "_"), [])))); - ((bool), ([16:3-12], (Happly (([Pos.none], "_"), []))))], + [], [(([16:13-15], (function(int, string): bool)), (Lvar ([16:13-15], $g))); (([16:17-20], Container), (Lvar ([16:17-20], $ci))); @@ -152,16 +149,11 @@ None))))); ([17:3-32], (Expr - (([17:3-31], varray>), + (([17:3-31], _), (Call ( - (([17:3-12], (function((function(int, string, num): Container) $callback, Container, Container, Container): varray>)), + (([17:3-12], (function($callback, $arr1, ...): _)), (Id ([17:3-12], "\\array_map"))), - [((int), ([17:3-12], (Happly (([Pos.none], "_"), [])))); - ((string), ([17:3-12], (Happly (([Pos.none], "_"), [])))); - ((num), ([17:3-12], (Happly (([Pos.none], "_"), [])))); - ((Container), - ([17:3-12], (Happly (([Pos.none], "_"), [])))) - ], + [], [(([17:13-15], (function(int, string, num): Container)), (Lvar ([17:13-15], $h))); (([17:17-20], Container), (Lvar ([17:17-20], $ci))); @@ -173,12 +165,11 @@ None))))); ([18:3-30], (Expr - (([18:3-29], darray), + (([18:3-29], darray), (Call ( - (([18:3-12], (function((function(num): bool) $callback, Container): darray)), + (([18:3-12], (function($callback, $arr1, ...): darray)), (Id ([18:3-12], "\\array_map"))), - [((num), ([18:3-12], (Happly (([Pos.none], "_"), [])))); - ((bool), ([18:3-12], (Happly (([Pos.none], "_"), []))))], + [], [(([18:13-15], (function(num): bool)), (Lvar ([18:13-15], $i))); (([18:17-28], (Container | KeyedContainer)), diff --git a/hphp/hack/test/typecheck/array/safe_vector_array/darray_with_array_map_does_not_return_vect_like_array.php b/hphp/hack/test/typecheck/array/safe_vector_array/darray_with_array_map_does_not_return_vect_like_array.php deleted file mode 100644 index 483e113a8f6..00000000000 --- a/hphp/hack/test/typecheck/array/safe_vector_array/darray_with_array_map_does_not_return_vect_like_array.php +++ /dev/null @@ -1,5 +0,0 @@ - { - return array_map($x ==> $x, darray["foo" => true, "bar" => false]); -} diff --git a/hphp/hack/test/typecheck/array/safe_vector_array/darray_with_array_map_does_not_return_vect_like_array.php.exp b/hphp/hack/test/typecheck/array/safe_vector_array/darray_with_array_map_does_not_return_vect_like_array.php.exp deleted file mode 100644 index 8abf7743fef..00000000000 --- a/hphp/hack/test/typecheck/array/safe_vector_array/darray_with_array_map_does_not_return_vect_like_array.php.exp +++ /dev/null @@ -1,12 +0,0 @@ -File "darray_with_array_map_does_not_return_vect_like_array.php", line 4, characters 10-68: -Invalid return type (Typing[4110]) - File "darray_with_array_map_does_not_return_vect_like_array.php", line 3, characters 35-46: - Expected `varray` - File "darray_with_array_map_does_not_return_vect_like_array.php", line 4, characters 31-67: - But got `darray<[unresolved], [unresolved]>` -File "darray_with_array_map_does_not_return_vect_like_array.php", line 4, characters 10-68: -Invalid return type (Typing[4110]) - File "darray_with_array_map_does_not_return_vect_like_array.php", line 3, characters 35-46: - Expected `varray` - File "darray_with_array_map_does_not_return_vect_like_array.php", line 4, characters 31-67: - But got `darray` diff --git a/hphp/hack/test/typecheck/array/safe_vector_array/darray_with_array_map_returns_dict_like_array.php b/hphp/hack/test/typecheck/array/safe_vector_array/darray_with_array_map_returns_dict_like_array.php deleted file mode 100644 index 046a421f5d9..00000000000 --- a/hphp/hack/test/typecheck/array/safe_vector_array/darray_with_array_map_returns_dict_like_array.php +++ /dev/null @@ -1,5 +0,0 @@ - { - return array_map($x ==> $x, darray["foo" => true, "bar" => false]); -} diff --git a/hphp/hack/test/typecheck/array/safe_vector_array/darray_with_array_map_returns_dict_like_array.php.exp b/hphp/hack/test/typecheck/array/safe_vector_array/darray_with_array_map_returns_dict_like_array.php.exp deleted file mode 100644 index 4269126fceb..00000000000 --- a/hphp/hack/test/typecheck/array/safe_vector_array/darray_with_array_map_returns_dict_like_array.php.exp +++ /dev/null @@ -1 +0,0 @@ -No errors diff --git a/hphp/hack/test/typecheck/array/safe_vector_array/darray_with_array_map_returns_dict_like_array.php.like_types.exp b/hphp/hack/test/typecheck/array/safe_vector_array/darray_with_array_map_returns_dict_like_array.php.like_types.exp deleted file mode 100644 index 156fc8d62a9..00000000000 --- a/hphp/hack/test/typecheck/array/safe_vector_array/darray_with_array_map_returns_dict_like_array.php.like_types.exp +++ /dev/null @@ -1,6 +0,0 @@ -File "darray_with_array_map_returns_dict_like_array.php", line 4, characters 10-68: -Invalid return type (Typing[4110]) - File "darray_with_array_map_returns_dict_like_array.php", line 3, characters 35-54: - Expected `darray` - File "stdlib/builtins_array.hhi", line 121, characters 10-18: - But got `varray<[unresolved]>` diff --git a/hphp/hack/test/typecheck/array/safe_vector_array/varray_with_array_map_does_not_return_dict_like_array.php b/hphp/hack/test/typecheck/array/safe_vector_array/varray_with_array_map_does_not_return_dict_like_array.php deleted file mode 100644 index e3bd2c09b17..00000000000 --- a/hphp/hack/test/typecheck/array/safe_vector_array/varray_with_array_map_does_not_return_dict_like_array.php +++ /dev/null @@ -1,5 +0,0 @@ - { - return array_map($x ==> $x, varray[1, 2, 3, 4, 5]); -} diff --git a/hphp/hack/test/typecheck/array/safe_vector_array/varray_with_array_map_does_not_return_dict_like_array.php.exp b/hphp/hack/test/typecheck/array/safe_vector_array/varray_with_array_map_does_not_return_dict_like_array.php.exp deleted file mode 100644 index 675986a4a1f..00000000000 --- a/hphp/hack/test/typecheck/array/safe_vector_array/varray_with_array_map_does_not_return_dict_like_array.php.exp +++ /dev/null @@ -1,6 +0,0 @@ -File "varray_with_array_map_does_not_return_dict_like_array.php", line 4, characters 10-52: -Invalid return type (Typing[4110]) - File "varray_with_array_map_does_not_return_dict_like_array.php", line 3, characters 35-50: - Expected `darray` - File "varray_with_array_map_does_not_return_dict_like_array.php", line 4, characters 31-51: - But got `varray<[unresolved]>` diff --git a/hphp/hack/test/typecheck/array_map_filter/array_map.php b/hphp/hack/test/typecheck/array_map_filter/array_map.php deleted file mode 100644 index f1605cade85..00000000000 --- a/hphp/hack/test/typecheck/array_map_filter/array_map.php +++ /dev/null @@ -1,10 +0,0 @@ - $a): void {} -function test( - (function(int, string): bool) $f, - Container $x, - Container $y, -): void { - expect_array_bool(array_map($f, $x, $y)); -} diff --git a/hphp/hack/test/typecheck/array_map_filter/array_map.php.exp b/hphp/hack/test/typecheck/array_map_filter/array_map.php.exp deleted file mode 100644 index 4269126fceb..00000000000 --- a/hphp/hack/test/typecheck/array_map_filter/array_map.php.exp +++ /dev/null @@ -1 +0,0 @@ -No errors diff --git a/hphp/hack/test/typecheck/array_map_filter/array_map1.php b/hphp/hack/test/typecheck/array_map_filter/array_map1.php deleted file mode 100644 index ddf41d72003..00000000000 --- a/hphp/hack/test/typecheck/array_map_filter/array_map1.php +++ /dev/null @@ -1,5 +0,0 @@ -((function(TA): TB) $f, vec $x): void { - array_map($f, $x); -} diff --git a/hphp/hack/test/typecheck/array_map_filter/array_map10.php.exp b/hphp/hack/test/typecheck/array_map_filter/array_map10.php.exp deleted file mode 100644 index f3926ff85c6..00000000000 --- a/hphp/hack/test/typecheck/array_map_filter/array_map10.php.exp +++ /dev/null @@ -1,12 +0,0 @@ -File "array_map10.php", line 4, characters 17-18: -Invalid argument (Typing[4110]) - File "array_map10.php", line 3, characters 37-38: - Expected `TA` - File "array_map10.php", line 3, characters 54-55: - But got `TC` - File "hackarray.hhi", line 25, characters 52-52: - via this generic `T` - File "hackarray.hhi", line 19, characters 77-78: - via this generic `Tv` - File "interfaces.hhi", line 123, characters 66-67: - via this generic `Tv` diff --git a/hphp/hack/test/typecheck/array_map_filter/array_map2.php b/hphp/hack/test/typecheck/array_map_filter/array_map2.php deleted file mode 100644 index 816b1fd4f9d..00000000000 --- a/hphp/hack/test/typecheck/array_map_filter/array_map2.php +++ /dev/null @@ -1,9 +0,0 @@ - $x, - Container $y, -): void { - array_map($f, $x, $y); -} diff --git a/hphp/hack/test/typecheck/array_map_filter/array_map2.php.exp b/hphp/hack/test/typecheck/array_map_filter/array_map2.php.exp deleted file mode 100644 index e548af2e72b..00000000000 --- a/hphp/hack/test/typecheck/array_map_filter/array_map2.php.exp +++ /dev/null @@ -1,6 +0,0 @@ -File "array_map2.php", line 8, characters 13-14: -Invalid argument (Typing[4040]) - File "array_map2.php", line 4, characters 3-23: - Too few arguments (required 2 but got 1) - File "stdlib/builtins_array.hhi", line 121, characters 20-28: - Because of this definition diff --git a/hphp/hack/test/typecheck/array_map_filter/array_map3.php b/hphp/hack/test/typecheck/array_map_filter/array_map3.php deleted file mode 100644 index 774837342ab..00000000000 --- a/hphp/hack/test/typecheck/array_map_filter/array_map3.php +++ /dev/null @@ -1,11 +0,0 @@ - $x) {} - -function test( - (function(int, string): bool) $f, - Container $x, - Container $y, -): void { - take_ints(array_map($f, $x, $y)); -} diff --git a/hphp/hack/test/typecheck/array_map_filter/array_map3.php.exp b/hphp/hack/test/typecheck/array_map_filter/array_map3.php.exp deleted file mode 100644 index 1d46407a7c9..00000000000 --- a/hphp/hack/test/typecheck/array_map_filter/array_map3.php.exp +++ /dev/null @@ -1,6 +0,0 @@ -File "array_map3.php", line 10, characters 23-24: -Invalid argument (Typing[4110]) - File "array_map3.php", line 3, characters 27-29: - Expected `int` - File "array_map3.php", line 6, characters 27-30: - But got `bool` diff --git a/hphp/hack/test/typecheck/array_map_filter/array_map4.php b/hphp/hack/test/typecheck/array_map_filter/array_map4.php deleted file mode 100644 index e61a10d781b..00000000000 --- a/hphp/hack/test/typecheck/array_map_filter/array_map4.php +++ /dev/null @@ -1,5 +0,0 @@ - $x): void { - array_map($x, $x); -} diff --git a/hphp/hack/test/typecheck/array_map_filter/array_map4.php.exp b/hphp/hack/test/typecheck/array_map_filter/array_map4.php.exp deleted file mode 100644 index e685e5692ba..00000000000 --- a/hphp/hack/test/typecheck/array_map_filter/array_map4.php.exp +++ /dev/null @@ -1,6 +0,0 @@ -File "array_map4.php", line 4, characters 13-14: -Invalid argument (Typing[4110]) - File "stdlib/builtins_array.hhi", line 121, characters 20-28: - Expected `(function([unresolved]): [unresolved])` - File "array_map4.php", line 3, characters 15-28: - But got `Container` diff --git a/hphp/hack/test/typecheck/array_map_filter/array_map5.php b/hphp/hack/test/typecheck/array_map_filter/array_map5.php deleted file mode 100644 index 63303f7abfa..00000000000 --- a/hphp/hack/test/typecheck/array_map_filter/array_map5.php +++ /dev/null @@ -1,5 +0,0 @@ -` - File "array_map5.php", line 3, characters 15-35: - But got `(function(int): bool)` diff --git a/hphp/hack/test/typecheck/array_map_filter/array_map7.php b/hphp/hack/test/typecheck/array_map_filter/array_map7.php deleted file mode 100644 index 7c2f65d2c34..00000000000 --- a/hphp/hack/test/typecheck/array_map_filter/array_map7.php +++ /dev/null @@ -1,37 +0,0 @@ - $vector_array, - darray $hashtable_array, - $untyped, - KeyedContainer $keyed_container, - Container $container, - Vector $vector, -) { - $f = fun('f'); - $g = fun('g'); - $intersection = true ? $vector_array : $keyed_container; - - take_bool_array(array_map($f, $vector_array)); - take_X_bool_array(array_map($f, $hashtable_array)); - hh_show(array_map($f, $untyped)); - take_arraykey_bool_array(array_map($f, $container)); - take_mixed_bool_array(array_map($f, $intersection)); - take_bool_array(array_map($f, $vector)); - take_bool_array(array_map($g, $intersection, $vector_array)); -} - -function take_bool_array(varray $_): void {} -function take_X_bool_array(darray $_): void {} -function take_arraykey_bool_array(darray $_): void {} -function take_mixed_bool_array(darray $_): void {} - -type X = arraykey; diff --git a/hphp/hack/test/typecheck/array_map_filter/array_map7.php.exp b/hphp/hack/test/typecheck/array_map_filter/array_map7.php.exp deleted file mode 100644 index b01eeb2c031..00000000000 --- a/hphp/hack/test/typecheck/array_map_filter/array_map7.php.exp +++ /dev/null @@ -1,14 +0,0 @@ -File "array_map7.php", line 25, characters 3-34: - _ -File "array_map7.php", line 27, characters 25-52: -Invalid argument (Typing[4110]) - File "array_map7.php", line 35, characters 32-50: - Expected `darray` - File "array_map7.php", line 12, characters 3-16: - But got `varray<[unresolved]>` -File "array_map7.php", line 27, characters 25-52: -Invalid argument (Typing[4110]) - File "array_map7.php", line 35, characters 32-50: - Expected `darray` - File "array_map7.php", line 12, characters 3-16: - But got `varray` diff --git a/hphp/hack/test/typecheck/array_map_filter/array_map7.php.like_types.exp b/hphp/hack/test/typecheck/array_map_filter/array_map7.php.like_types.exp deleted file mode 100644 index d51ba124116..00000000000 --- a/hphp/hack/test/typecheck/array_map_filter/array_map7.php.like_types.exp +++ /dev/null @@ -1,38 +0,0 @@ -File "array_map7.php", line 25, characters 3-34: - ~varray -File "array_map7.php", line 24, characters 21-51: -Invalid argument (Typing[4110]) - File "array_map7.php", line 33, characters 28-42: - Expected `darray` - File "stdlib/builtins_array.hhi", line 121, characters 10-18: - But got `varray<[unresolved]>` -File "array_map7.php", line 24, characters 21-51: -Invalid argument (Typing[4110]) - File "array_map7.php", line 33, characters 28-42: - Expected `darray` - File "stdlib/builtins_array.hhi", line 121, characters 10-18: - But got `varray` -File "array_map7.php", line 26, characters 28-52: -Invalid argument (Typing[4110]) - File "array_map7.php", line 34, characters 35-56: - Expected `darray` - File "stdlib/builtins_array.hhi", line 121, characters 10-18: - But got `varray<[unresolved]>` -File "array_map7.php", line 26, characters 28-52: -Invalid argument (Typing[4110]) - File "array_map7.php", line 34, characters 35-56: - Expected `darray` - File "stdlib/builtins_array.hhi", line 121, characters 10-18: - But got `varray` -File "array_map7.php", line 27, characters 25-52: -Invalid argument (Typing[4110]) - File "array_map7.php", line 35, characters 32-50: - Expected `darray` - File "stdlib/builtins_array.hhi", line 121, characters 10-18: - But got `varray<[unresolved]>` -File "array_map7.php", line 27, characters 25-52: -Invalid argument (Typing[4110]) - File "array_map7.php", line 35, characters 32-50: - Expected `darray` - File "stdlib/builtins_array.hhi", line 121, characters 10-18: - But got `varray` diff --git a/hphp/hack/test/typecheck/array_map_filter/array_map9.php b/hphp/hack/test/typecheck/array_map_filter/array_map9.php deleted file mode 100644 index d33693ab6b6..00000000000 --- a/hphp/hack/test/typecheck/array_map_filter/array_map9.php +++ /dev/null @@ -1,5 +0,0 @@ -(TA $a, TB $b): void { - array_map($x ==> $x, vec[$a, $b]); -} diff --git a/hphp/hack/test/typecheck/array_map_filter/array_map9.php.exp b/hphp/hack/test/typecheck/array_map_filter/array_map9.php.exp deleted file mode 100644 index 4269126fceb..00000000000 --- a/hphp/hack/test/typecheck/array_map_filter/array_map9.php.exp +++ /dev/null @@ -1 +0,0 @@ -No errors diff --git a/hphp/hack/test/typecheck/array_map_filter/array_map_explicitly_typed.php b/hphp/hack/test/typecheck/array_map_filter/array_map_explicitly_typed.php deleted file mode 100644 index a43c75de9ac..00000000000 --- a/hphp/hack/test/typecheck/array_map_filter/array_map_explicitly_typed.php +++ /dev/null @@ -1,7 +0,0 @@ -(function($x, $y) { return $x + $y; }, vec[1, 2], vec[2,3]); - return $x[0]; -} diff --git a/hphp/hack/test/typecheck/array_map_filter/array_map_explicitly_typed.php.exp b/hphp/hack/test/typecheck/array_map_filter/array_map_explicitly_typed.php.exp deleted file mode 100644 index 4269126fceb..00000000000 --- a/hphp/hack/test/typecheck/array_map_filter/array_map_explicitly_typed.php.exp +++ /dev/null @@ -1 +0,0 @@ -No errors diff --git a/hphp/hack/test/typecheck/array_map_filter/array_map_explicitly_typed_arity.php b/hphp/hack/test/typecheck/array_map_filter/array_map_explicitly_typed_arity.php deleted file mode 100644 index 335675c592b..00000000000 --- a/hphp/hack/test/typecheck/array_map_filter/array_map_explicitly_typed_arity.php +++ /dev/null @@ -1,7 +0,0 @@ -(function($x, $y) { return $x + $y; }, vec[1, 2], vec[2,3]); - return $x[0]; -} diff --git a/hphp/hack/test/typecheck/array_map_filter/array_map_explicitly_typed_arity.php.exp b/hphp/hack/test/typecheck/array_map_filter/array_map_explicitly_typed_arity.php.exp deleted file mode 100644 index 9ad006af69e..00000000000 --- a/hphp/hack/test/typecheck/array_map_filter/array_map_explicitly_typed_arity.php.exp +++ /dev/null @@ -1,4 +0,0 @@ -File "array_map_explicitly_typed_arity.php", line 5, characters 8-16: -Expected 3 type parameters (Typing[4029]) - File "stdlib/builtins_array.hhi", line 121, characters 10-18: - Definition is here diff --git a/hphp/hack/test/typecheck/array_map_filter/array_map_explicitly_typed_error.php b/hphp/hack/test/typecheck/array_map_filter/array_map_explicitly_typed_error.php deleted file mode 100644 index dc6b5df3b8c..00000000000 --- a/hphp/hack/test/typecheck/array_map_filter/array_map_explicitly_typed_error.php +++ /dev/null @@ -1,11 +0,0 @@ -( - function($x, $y) { - return $x + $y; }, - vec[1, 2], - vec[2,3]); - return $x[0]; -} diff --git a/hphp/hack/test/typecheck/array_map_filter/array_map_explicitly_typed_error.php.exp b/hphp/hack/test/typecheck/array_map_filter/array_map_explicitly_typed_error.php.exp deleted file mode 100644 index 8134e7d87dc..00000000000 --- a/hphp/hack/test/typecheck/array_map_filter/array_map_explicitly_typed_error.php.exp +++ /dev/null @@ -1,22 +0,0 @@ -File "array_map_explicitly_typed_error.php", line 7, characters 14-20: -Typing error (Typing[4110]) - File "array_map_explicitly_typed_error.php", line 7, characters 14-15: - Expected `num` because this is used in an arithmetic operation - File "array_map_explicitly_typed_error.php", line 6, characters 14-15: - But got `string` because the type of the lambda parameter could not be determined. Please add a type hint to the parameter -File "array_map_explicitly_typed_error.php", line 8, characters 5-13: -Some elements in this collection are incompatible (Typing[4110]) - File "array_map_explicitly_typed_error.php", line 5, characters 18-23: - Expected `string` - File "stdlib/builtins_array.hhi", line 121, characters 31-35: - via this generic `T1` - File "array_map_explicitly_typed_error.php", line 8, characters 9-9: - But got `int` -File "array_map_explicitly_typed_error.php", line 8, characters 5-13: -Some elements in this collection are incompatible (Typing[4110]) - File "array_map_explicitly_typed_error.php", line 5, characters 18-23: - Expected `string` - File "stdlib/builtins_array.hhi", line 121, characters 31-35: - via this generic `T1` - File "array_map_explicitly_typed_error.php", line 8, characters 12-12: - But got `int` diff --git a/hphp/hack/test/typecheck/deprecated_fun_id.php b/hphp/hack/test/typecheck/deprecated_fun_id.php deleted file mode 100644 index f5ad64c2bca..00000000000 --- a/hphp/hack/test/typecheck/deprecated_fun_id.php +++ /dev/null @@ -1,8 +0,0 @@ -> -function foo() {} - -function f() { - array_map(fun('foo'), varray[]); -} diff --git a/hphp/hack/test/typecheck/deprecated_fun_id.php.exp b/hphp/hack/test/typecheck/deprecated_fun_id.php.exp deleted file mode 100644 index 65965aebb08..00000000000 --- a/hphp/hack/test/typecheck/deprecated_fun_id.php.exp +++ /dev/null @@ -1,10 +0,0 @@ -File "deprecated_fun_id.php", line 7, characters 13-22: -Invalid argument (Typing[4040]) - File "deprecated_fun_id.php", line 4, characters 10-12: - Too few arguments (required 1 but got 0) - File "stdlib/builtins_array.hhi", line 121, characters 20-28: - Because of this definition -File "deprecated_fun_id.php", line 7, characters 17-21: -The function foo is deprecated: use bar() instead (Typing[4128]) - File "deprecated_fun_id.php", line 4, characters 10-12: - Definition is here diff --git a/hphp/hack/test/typecheck/unused_awaitable16.php b/hphp/hack/test/typecheck/unused_awaitable16.php deleted file mode 100644 index 1e9ae2deea5..00000000000 --- a/hphp/hack/test/typecheck/unused_awaitable16.php +++ /dev/null @@ -1,10 +0,0 @@ - { - return 'hehe'; -} - -async function g(): Awaitable { - $gens = darray['a' => f(), 'b' => f(), 'c' => f()]; - $gens = array_map($item ==> (bool)$item, $gens); -} diff --git a/hphp/hack/test/typecheck/unused_awaitable16.php.exp b/hphp/hack/test/typecheck/unused_awaitable16.php.exp deleted file mode 100644 index 9c0cb869473..00000000000 --- a/hphp/hack/test/typecheck/unused_awaitable16.php.exp +++ /dev/null @@ -1,4 +0,0 @@ -File "unused_awaitable16.php", line 9, characters 37-41: -This expression is of type `Awaitable`, but it's either being discarded or used in a dangerous way before being awaited (Typing[4015]) -File "unused_awaitable16.php", line 3, characters 21-37: -This is why I think it is `Awaitable` diff --git a/hphp/hack/test/typecheck/void_usage_5.php b/hphp/hack/test/typecheck/void_usage_5.php deleted file mode 100644 index 185dec52018..00000000000 --- a/hphp/hack/test/typecheck/void_usage_5.php +++ /dev/null @@ -1,16 +0,0 @@ - { - if ($b) { - return $x; - } - }, - varray['test'], - ); - foreach ($arr as $x) { - if ($x) { - } - } -} diff --git a/hphp/hack/test/typecheck/void_usage_5.php.exp b/hphp/hack/test/typecheck/void_usage_5.php.exp deleted file mode 100644 index a7e0eab0321..00000000000 --- a/hphp/hack/test/typecheck/void_usage_5.php.exp +++ /dev/null @@ -1,10 +0,0 @@ -File "void_usage_5.php", line 5, characters 5-61: -Invalid return type (Typing[4336]) -File "void_usage_5.php", line 5, characters 5-61: -Expected `void` because this function does not always return a value -File "void_usage_5.php", line 10, characters 12-17: -But got `string` -File "void_usage_5.php", line 13, characters 9-10: -You are using the return value of a `void` function (Typing[4119]) -File "void_usage_5.php", line 5, characters 5-61: -A `void` function doesn't return a value. because this function does not always return a value -- 2.11.4.GIT