From 5ae19306221d992a897156312dce98b7934c10bc Mon Sep 17 00:00:00 2001 From: Jake Bailey Date: Thu, 12 Apr 2018 10:33:27 -0700 Subject: [PATCH] Type unbound global IDs and hh pseudofunctions in TAST Summary: In the interest of making every expression explicitly typed, this change types unbound globals as `Terr` and hh pseudofunctions like `hh_show` as `Tany` in the TAST. Reviewed By: pittsw Differential Revision: D7495815 fbshipit-source-id: 27de403fdd57bbb23a382d5e199aeb34a55ab786 --- hphp/hack/src/typing/typing.ml | 4 ++-- hphp/hack/test/tast/switch_fallthrough.php.exp | 18 +++++++++--------- hphp/hack/test/tast/unbound_global.php.exp | 2 +- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/hphp/hack/src/typing/typing.ml b/hphp/hack/src/typing/typing.ml index 1bb9f28ce4a..2e80a594fcd 100644 --- a/hphp/hack/src/typing/typing.ml +++ b/hphp/hack/src/typing/typing.ml @@ -1505,7 +1505,7 @@ and expr_ | None when Env.is_strict env -> Errors.unbound_global cst_pos; let ty = (Reason.Rwitness cst_pos, Typing_utils.terr env) in - let te = T.make_implicitly_typed_expr cst_pos (T.Id id) in + let te = T.make_typed_expr cst_pos ty (T.Id id) in env, te, ty | None -> make_result env (T.Id id) (Reason.Rwitness cst_pos, Typing_utils.tany env) @@ -1762,7 +1762,7 @@ and expr_ make_result env (T.Call( Cnormal, - T.make_implicitly_typed_expr pos_id (T.Id id), + T.make_typed_expr pos_id (Reason.Rnone, TUtils.tany env) (T.Id id), hl, tel, [])) (Env.fresh_type()) diff --git a/hphp/hack/test/tast/switch_fallthrough.php.exp b/hphp/hack/test/tast/switch_fallthrough.php.exp index fb132261e90..310c04d64e9 100644 --- a/hphp/hack/test/tast/switch_fallthrough.php.exp +++ b/hphp/hack/test/tast/switch_fallthrough.php.exp @@ -36,7 +36,7 @@ File "switch_fallthrough.php", line 37, characters 3-13: (AnnotatedAST.Expr (([6:3-6:14], Some _), (AnnotatedAST.Call (Cnormal, - (([6:3-6:10], None), + (([6:3-6:10], Some _), (AnnotatedAST.Id ([6:3-6:10], "\\hh_show"))), [], [(([6:11-6:13], Some int), @@ -55,7 +55,7 @@ File "switch_fallthrough.php", line 37, characters 3-13: [(AnnotatedAST.Expr (([12:7-12:18], Some _), (AnnotatedAST.Call (Cnormal, - (([12:7-12:14], None), + (([12:7-12:14], Some _), (AnnotatedAST.Id ([12:7-12:14], "\\hh_show"))), [], [(([12:15-12:17], Some int), @@ -72,7 +72,7 @@ File "switch_fallthrough.php", line 37, characters 3-13: (AnnotatedAST.Expr (([15:7-15:18], Some _), (AnnotatedAST.Call (Cnormal, - (([15:7-15:14], None), + (([15:7-15:14], Some _), (AnnotatedAST.Id ([15:7-15:14], "\\hh_show"))), [], [(([15:15-15:17], Some string), @@ -86,7 +86,7 @@ File "switch_fallthrough.php", line 37, characters 3-13: [(AnnotatedAST.Expr (([19:7-19:18], Some _), (AnnotatedAST.Call (Cnormal, - (([19:7-19:14], None), + (([19:7-19:14], Some _), (AnnotatedAST.Id ([19:7-19:14], "\\hh_show"))), [], [(([19:15-19:17], Some (int | string)), @@ -102,7 +102,7 @@ File "switch_fallthrough.php", line 37, characters 3-13: (AnnotatedAST.Expr (([22:7-22:18], Some _), (AnnotatedAST.Call (Cnormal, - (([22:7-22:14], None), + (([22:7-22:14], Some _), (AnnotatedAST.Id ([22:7-22:14], "\\hh_show"))), [], [(([22:15-22:17], Some bool), @@ -116,7 +116,7 @@ File "switch_fallthrough.php", line 37, characters 3-13: [(AnnotatedAST.Expr (([26:7-26:18], Some _), (AnnotatedAST.Call (Cnormal, - (([26:7-26:14], None), + (([26:7-26:14], Some _), (AnnotatedAST.Id ([26:7-26:14], "\\hh_show"))), [], [(([26:15-26:17], Some (string | bool | int)), @@ -130,7 +130,7 @@ File "switch_fallthrough.php", line 37, characters 3-13: [(AnnotatedAST.Expr (([30:7-30:18], Some _), (AnnotatedAST.Call (Cnormal, - (([30:7-30:14], None), + (([30:7-30:14], Some _), (AnnotatedAST.Id ([30:7-30:14], "\\hh_show"))), [], [(([30:15-30:17], Some int), @@ -147,7 +147,7 @@ File "switch_fallthrough.php", line 37, characters 3-13: (AnnotatedAST.Expr (([33:7-33:18], Some _), (AnnotatedAST.Call (Cnormal, - (([33:7-33:14], None), + (([33:7-33:14], Some _), (AnnotatedAST.Id ([33:7-33:14], "\\hh_show"))), [], [(([33:15-33:17], Some float), @@ -160,7 +160,7 @@ File "switch_fallthrough.php", line 37, characters 3-13: (AnnotatedAST.Expr (([37:3-37:14], Some _), (AnnotatedAST.Call (Cnormal, - (([37:3-37:10], None), + (([37:3-37:10], Some _), (AnnotatedAST.Id ([37:3-37:10], "\\hh_show"))), [], [(([37:11-37:13], Some (int | string | float | bool)), diff --git a/hphp/hack/test/tast/unbound_global.php.exp b/hphp/hack/test/tast/unbound_global.php.exp index 1a40ccf0b26..284bc8e2613 100644 --- a/hphp/hack/test/tast/unbound_global.php.exp +++ b/hphp/hack/test/tast/unbound_global.php.exp @@ -11,7 +11,7 @@ Errors: (AnnotatedAST.NamedBody { AnnotatedAST.fnb_nast = [(AnnotatedAST.Expr - (([4:3-4:17], None), + (([4:3-4:17], Some _), (AnnotatedAST.Id ([4:3-4:17], "\\unbound_global")))) ]; fnb_unsafe = false }); -- 2.11.4.GIT