2 * Copyright (c) 2018, Facebook, Inc.
5 * This source code is licensed under the MIT license found in the
6 * LICENSE file in the "hack" directory of this source tree.
16 let check_types env
((p
, _
), te
) =
17 let rec check_types_helper = function
19 | Array_get
(((_
, ty1
), te1
), Some _
) ->
21 let _, ety1
= Env.expand_type env ty1
in
24 | _, (Tarraykind
_ | Ttuple
_ | Tshape
_) -> true
25 | _, Tclass
((_, cn
), _, _)
26 when cn
= SN.Collections.cDict
27 || cn
= SN.Collections.cKeyset
28 || cn
= SN.Collections.cVec
-> true
29 | _, Tunion tyl
-> List.for_all ~f
:iter tyl
31 let _, tyl
= Env.get_concrete_supertypes env ety1
in
32 List.exists ~f
:iter tyl
35 then check_types_helper te1
37 let ty_str = Env.print_error_ty env ty1
in
38 let msgl = Reason.to_string
("This is " ^
ty_str) (fst ty1
) in
39 Errors.inout_argument_bad_type p
msgl
40 (* Other invalid expressions are caught in NastCheck. *)
45 inherit Tast_visitor.handler_base
47 method! at_expr env
= function
48 | _, Callconv
(_, te
) -> check_types env te