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.
14 module SN
= Naming_special_names
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
22 match get_node ety1
with
29 | Tclass
((_
, cn
), _
, _
)
30 when String.equal cn
SN.Collections.cDict
31 || String.equal cn
SN.Collections.cKeyset
32 || String.equal cn
SN.Collections.cVec
->
34 | Tunion tyl
-> List.for_all ~f
:iter tyl
35 | Tintersection tyl
-> List.exists ~f
:iter tyl
40 Env.get_concrete_supertypes ~abstract_enum
:true env ety1
42 List.exists ~f
:iter tyl
46 check_types_helper te1
48 let ty_str = lazy (Env.print_error_ty env ty1
) in
50 Lazy.map
ty_str ~f
:(fun ty_str ->
51 Reason.to_string
("This is " ^
ty_str) (get_reason ty1
))
53 Typing_error_utils.add_typing_error
54 ~env
:(Env.tast_env_as_typing_env env
)
56 primary
@@ Primary.Inout_argument_bad_type
{ pos
= p
; reasons })
57 (* Other invalid expressions are caught in Nast_check. *)
64 inherit Tast_visitor.handler_base
68 | (_
, _
, Call
{ args
; _
}) ->
71 | (Ast_defs.Pnormal
, _
) -> ()
72 | (Ast_defs.Pinout _
, e
) -> check_types env e
)