Skip to content

Commit 5b0e305

Browse files
Michael Thomasmeta-codesync[bot]
authored andcommitted
Revert D85155666
Summary: Reverts changes in D85155666 whilst we investigate a memory regression Reviewed By: andrewjkennedy, francesco-zappa-nardelli Differential Revision: D90175268 fbshipit-source-id: ebf88f50f746696a1063109bbcaf66106933637c
1 parent 2f1e842 commit 5b0e305

16 files changed

+39
-487
lines changed

hphp/hack/hhi/func_pointers.hhi

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* LICENSE file in the "hack" directory of this source tree.
88
*
99
*/
10-
<<file:__EnableUnstableFeatures('class_type','open_tuples', 'type_splat')>>
10+
<<file:__EnableUnstableFeatures('class_type')>>
1111
namespace HH {
1212

1313
// The functions in this file are defined in HHVM and known to the
@@ -65,11 +65,10 @@ namespace HH {
6565
*
6666
* See http://docs.hhvm.com/hack/reference/function/HH.invariant/
6767
*/
68-
<<__NoAutoLikes>>
69-
function invariant<Targs as (mixed...)>(
68+
function invariant(
7069
\HH\FIXME\MISSING_PARAM_TYPE $condition,
71-
\HH\TypedFormatString<\PlainSprintf, Targs> $f,
72-
...Targs $f_args
70+
FormatString<\PlainSprintf> $f,
71+
mixed ...$f_args
7372
)[]: void; // becomes:
7473
// if (!(<condition>)) { // an Exception is thrown
7574
// invariant_violation('sprintf format: %s', 'string', ...);

hphp/hack/hhi/printf.hhi

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* LICENSE file in the "hack" directory of this source tree.
88
*
99
*/
10-
<<file: __EnableUnstableFeatures('open_tuples', 'type_splat')>>
10+
1111
namespace {
1212

1313
/**
@@ -95,21 +95,21 @@ namespace {
9595
* If possible, upgrade to \HH\Lib\Str\format().
9696
* This uses the far stricter \HH\Lib\Str\SprintfFormat type.
9797
*/
98-
<<__PHPStdLib, __NoAutoLikes>>
99-
function sprintf<Targs as (mixed...)>(
100-
\HH\TypedFormatString<PlainSprintf,Targs> $fmt,
101-
...Targs $fmt_args
98+
<<__PHPStdLib>>
99+
function sprintf(
100+
\HH\FormatString<PlainSprintf> $fmt,
101+
HH\FIXME\MISSING_PARAM_TYPE ...$fmt_args
102102
)[]: string;
103103
/**
104104
* printf uses PlainSprintf as its format string.
105105
* This type is very wide and will allow many incorrect calls to typecheck.
106106
* If possible, upgrade to \HH\Lib\Str\format().
107107
* This uses the far stricter \HH\Lib\Str\SprintfFormat type.
108108
*/
109-
<<__PHPStdLib, __NoAutoLikes>>
110-
function printf<Targs as (mixed...)>(
111-
\HH\TypedFormatString<PlainSprintf,Targs> $fmt,
112-
...Targs $fmt_args
109+
<<__PHPStdLib>>
110+
function printf(
111+
\HH\FormatString<PlainSprintf> $fmt,
112+
HH\FIXME\MISSING_PARAM_TYPE ...$fmt_args
113113
): int;
114114

115115
}
@@ -119,10 +119,9 @@ namespace HH {
119119
// Results in an \HH\InvariantException whose message is the result of
120120
// calling sprintf with the arguments given this function.
121121
// Equivalent to invariant(false, $fmt, ...$fmt_args).
122-
<<__NoAutoLikes>>
123-
function invariant_violation<Targs as (mixed...)>(
124-
TypedFormatString<\PlainSprintf,Targs> $fmt,
125-
...Targs $fmt_args
122+
function invariant_violation(
123+
FormatString<\PlainSprintf> $fmt,
124+
mixed ...$fmt_args
126125
)[]: noreturn;
127126

128127
}

hphp/hack/hhi/typenames.hhi

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
<?hh
2-
<<file: __EnableUnstableFeatures('open_tuples')>>
3-
namespace HH {
4-
newtype FormatString<T> as TypedFormatString<T, (mixed...)> = string;
52

6-
newtype TypedFormatString<T, Targs as (mixed...)> as string = string;
3+
namespace HH {
4+
newtype FormatString<T> as string = string;
75

86
<<__NoAutoDynamic>>
97
newtype FunctionRef<T> as T = T;

hphp/hack/src/naming/naming_special_names.ml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,8 @@ module Classes = struct
3030

3131
let cHHFormatString = "\\HH\\FormatString"
3232

33-
let cHHTypedFormatString = "\\HH\\TypedFormatString"
34-
3533
let is_format_string x = String.equal x cHHFormatString
3634

37-
let is_typed_format_string x = String.equal x cHHTypedFormatString
38-
3935
let cHH_BuiltinEnum = "\\HH\\BuiltinEnum"
4036

4137
let cHH_BuiltinEnumClass = "\\HH\\BuiltinEnumClass"

hphp/hack/src/typing/typing.ml

Lines changed: 3 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -3529,33 +3529,7 @@ end = struct
35293529
*)
35303530
| Null -> make_result env p Aast.Null (MakeType.null (Reason.witness p))
35313531
| String s ->
3532-
let (env, expected) =
3533-
Env_help.expand_expected_opt
3534-
~strip_supportdyn:false
3535-
~pessimisable_builtin:false
3536-
env
3537-
expected
3538-
in
3539-
begin
3540-
match expected with
3541-
| Some (_pos, _ur, _, _, Tnewtype (fs, [ty; _], _))
3542-
when SN.Classes.is_typed_format_string fs ->
3543-
let (env, fpl) = Typing_exts.parse_printf_string env s p ty in
3544-
let tuple_ty =
3545-
Typing_make_type.tuple
3546-
(Reason.witness p)
3547-
(List.map fpl ~f:(fun fp -> fp.fp_type))
3548-
in
3549-
let string_ty =
3550-
mk
3551-
( Reason.witness p,
3552-
Tnewtype (fs, [ty; tuple_ty], MakeType.string (Reason.witness p))
3553-
)
3554-
in
3555-
make_result env p (Aast.String s) string_ty
3556-
| _ ->
3557-
make_result env p (Aast.String s) (MakeType.string (Reason.witness p))
3558-
end
3532+
make_result env p (Aast.String s) (MakeType.string (Reason.witness p))
35593533
| String2 idl ->
35603534
let (env, tel) = string2 env idl in
35613535
make_result env p (Aast.String2 tel) (MakeType.string (Reason.witness p))
@@ -12206,42 +12180,17 @@ end = struct
1220612180
(Aast.Binop { bop; lhs = te1; rhs = te2 })
1220712181
(MakeType.bool (Reason.logic_ret p))
1220812182
| _ ->
12209-
let (env, expected) =
12210-
match bop with
12211-
| Ast_defs.Dot ->
12212-
Env_help.expand_expected_opt
12213-
~strip_supportdyn:false
12214-
~pessimisable_builtin:false
12215-
env
12216-
expected
12217-
| _ -> (env, None)
12218-
in
12219-
let (env, expected) =
12220-
match expected with
12221-
| Some (pos, ur, _, _, Tnewtype (fs, [ty; _], bound))
12222-
when SN.Classes.is_typed_format_string fs ->
12223-
let (env, fresh_ty) = Env.fresh_type env p in
12224-
let expected =
12225-
ExpectedTy.make
12226-
pos
12227-
ur
12228-
(mk
12229-
(Reason.concat_operand p, Tnewtype (fs, [ty; fresh_ty], bound)))
12230-
in
12231-
(env, Some expected)
12232-
| _ -> (env, None)
12233-
in
1223412183
let (env, te1, ty1) =
1223512184
Expr.expr
12236-
~expected
12185+
~expected:None
1223712186
~ctxt:Expr.Context.{ default with check_defined }
1223812187
env
1223912188
e1
1224012189
in
1224112190
let (env, te2, ty2) =
1224212191
check_e2
1224312192
(Expr.expr
12244-
~expected
12193+
~expected:None
1224512194
~ctxt:Expr.Context.{ default with check_defined })
1224612195
env
1224712196
e2

hphp/hack/src/typing/typing_arithmetic.ml

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -575,32 +575,7 @@ let binop p env bop p1 te1 ty1 p2 te2 ty2 =
575575
in
576576
let (env, err_opt1) = sub_arraykey env p1 ty1 in
577577
let (env, err_opt2) = sub_arraykey env p2 ty2 in
578-
let r = Reason.concat_ret p in
579-
let ty =
580-
begin
581-
(* Special case for TypedFormatString operands.
582-
* If e1 has type TypedFormatString<I,(t1,...,tn)>
583-
* and e2 has type TypedFormatString<I,(u1,...,um)>
584-
* then e1 . e2 has type TypedFormatString<I,(t1,...,tn,u1,...,um)>
585-
*)
586-
match (get_node ty1, get_node ty2) with
587-
| ( Tnewtype (fs1, [ty1; tuple1], _),
588-
Tnewtype (fs2, [ty2; tuple2], bound) )
589-
when SN.Classes.is_typed_format_string fs1
590-
&& SN.Classes.is_typed_format_string fs2
591-
&& Typing_defs.equal_locl_ty ty1 ty2 -> begin
592-
match (get_node tuple1, get_node tuple2) with
593-
| ( Ttuple { t_required = req1; t_optional = []; t_extra = _ },
594-
Ttuple { t_required = req2; t_optional = []; t_extra = _ } ) ->
595-
mk
596-
( r,
597-
Tnewtype
598-
(fs1, [ty1; Typing_make_type.tuple r (req1 @ req2)], bound) )
599-
| _ -> MakeType.string r
600-
end
601-
| _ -> MakeType.string r
602-
end
603-
in
578+
let ty = MakeType.string (Reason.concat_ret p) in
604579
make_result env te1 err_opt1 te2 err_opt2 ty
605580
| Ast_defs.Barbar
606581
| Ast_defs.Ampamp ->

hphp/hack/src/typing/typing_exts.mli

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,3 @@ val retype_magic_func :
2828
Typing_defs.locl_fun_type ->
2929
Nast.argument list ->
3030
Typing_env_types.env * Typing_defs.locl_fun_type
31-
32-
val parse_printf_string :
33-
Typing_env_types.env ->
34-
string ->
35-
Pos.t ->
36-
Typing_defs.locl_ty ->
37-
Typing_env_types.env * Typing_defs.locl_fun_params

hphp/hack/test/hover/invariant.php.exp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
function invariant<Targs as (mixed...)>(
1+
function invariant(
22
HH\FIXME\MISSING_PARAM_TYPE $condition,
3-
HH\TypedFormatString<PlainSprintf, Targs> $f,
4-
...Targs $f_args
3+
HH\FormatString<PlainSprintf> $f,
4+
mixed $f_args...
55
)[]: void
66
---
77
Call `invariant_violation` if the condition is false.

hphp/hack/test/tast/pseudofunctions.php.exp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,19 +81,17 @@ Errors:
8181
(Expr
8282
((noreturn), [19:3-25],
8383
(Call
84-
{ func =
85-
(((function<Targs as (mixed...)>(HH\TypedFormatString<PlainSprintf, ()> $fmt, ...() $fmt_args)[]: noreturn)), [19:3-12], (Id ([19:3-12], "\\HH\\invariant_violation")));
86-
targs = [((()), ([19:3-12], Hwildcard))];
87-
args = [(Anormal ((HH\TypedFormatString<~PlainSprintf, ()>), [19:19-24], (String "foo")))];
84+
{ func = (((function(HH\FormatString<PlainSprintf> $fmt, mixed $fmt_args...)[]: noreturn)), [19:3-12], (Id ([19:3-12], "\\HH\\invariant_violation")));
85+
targs = []; args = [(Anormal ((string), [19:19-24], (String "foo")))];
8886
unpacked_arg = None }))))
8987
],
9088
[([Pos.none], Noop)])));
9189
([20:3-30],
9290
(Expr
9391
((noreturn), [20:3-29],
9492
(Call
95-
{ func = (((function<Targs as (mixed...)>(HH\TypedFormatString<PlainSprintf, ()> $fmt, ...() $fmt_args)[]: noreturn)), [20:3-22], (Id ([20:3-22], "\\HH\\invariant_violation")));
96-
targs = [((()), ([20:3-22], Hwildcard))]; args = [(Anormal ((HH\TypedFormatString<~PlainSprintf, ()>), [20:23-28], (String "foo")))];
93+
{ func = (((function(HH\FormatString<PlainSprintf> $fmt, mixed $fmt_args...)[]: noreturn)), [20:3-22], (Id ([20:3-22], "\\HH\\invariant_violation")));
94+
targs = []; args = [(Anormal ((string), [20:23-28], (String "foo")))];
9795
unpacked_arg = None }))))
9896
]
9997
};

hphp/hack/test/typecheck/inout/pseudofunction_with_signature.php.exp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ ERROR: File "pseudofunction_with_signature.php", line 9, characters 28-30:
66
No class constant `T` in `dict` (Typing[4090])
77
File "hackarray.hhi", line 32, characters 24-27:
88
Declaration of `dict` is here
9+
ERROR: File "pseudofunction_with_signature.php", line 10, characters 16-23:
10+
Unexpected `inout` annotation for argument (Typing[4183])
11+
File "printf.hhi", line 48, characters 40-41:
12+
This is a normal parameter (does not have `inout`)
913
ERROR: File "pseudofunction_with_signature.php", line 11, characters 11-18:
1014
Unexpected `inout` annotation for argument (Typing[4183])
1115
File "stdlib/builtins_variable.hhi", line 35, characters 35-38:

0 commit comments

Comments
 (0)