From 5271e5077ed2d70264b402f5b5fc1fc428d5c6f7 Mon Sep 17 00:00:00 2001 From: Vassil Mladenov Date: Sat, 2 Jan 2021 19:44:46 -0800 Subject: [PATCH] Don't string match function names for Typing_env pseudo functions Summary: This is the same problem covered in {D25729833 (https://github.com/facebook/hhvm/commit/afe98128f68b81083c70db41e1ecfbc6c2476563)}. This is especially bad because these are debugging functions which never appear in WWW, but we're wasting time checking for their names. Reviewed By: periodic1236 Differential Revision: D25740041 fbshipit-source-id: 119ac834d2c390207cc6a73db8791d1e2f09202b --- hphp/hack/src/typing/typing.ml | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/hphp/hack/src/typing/typing.ml b/hphp/hack/src/typing/typing.ml index 3aff7eb6350..0cf8b880b70 100644 --- a/hphp/hack/src/typing/typing.ml +++ b/hphp/hack/src/typing/typing.ml @@ -1284,12 +1284,14 @@ and lvalues env el = let (env, tel, tyl) = lvalues env el in (env, te :: tel, ty :: tyl) -and is_pseudo_function s = - String.equal s SN.PseudoFunctions.hh_show - || String.equal s SN.PseudoFunctions.hh_show_env - || String.equal s SN.PseudoFunctions.hh_log_level - || String.equal s SN.PseudoFunctions.hh_force_solve - || String.equal s SN.PseudoFunctions.hh_loop_forever +(* These functions invoke special printing functions for Typing_env. They do not + * appear in user code, but we still check top level function calls against their + * names. *) +and typing_env_pseudofunctions = + SN.PseudoFunctions.( + String.Hash_set.of_list + ~growth_allowed:false + [hh_show; hh_show_env; hh_log_level; hh_force_solve; hh_loop_forever]) and loop_forever env = (* forever = up to 10 minutes, to avoid accidentally stuck processes *) @@ -2120,8 +2122,8 @@ and expr_ ty2 in make_result env p (Aast.Array_get (te1, Some te2)) ty - | Call ((pos_id, Id ((_, s) as id)), [], el, None) when is_pseudo_function s - -> + | Call ((pos_id, Id ((_, s) as id)), [], el, None) + when Hash_set.mem typing_env_pseudofunctions s -> let (env, tel, tys) = exprs ~accept_using_var:true env el in let env = if String.equal s SN.PseudoFunctions.hh_show then ( -- 2.11.4.GIT