Skip to content

Commit

Permalink
darray and varray permit zero type arguments in non-strict files
Browse files Browse the repository at this point in the history
Reviewed By: KendallHopkins

Differential Revision: D5023838

fbshipit-source-id: 218d2014a31f62bada2384165247ccdb932ba8f0
  • Loading branch information
michaeltingley authored and hhvm-bot committed May 9, 2017
1 parent 2a45f66 commit 6818d4c
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 4 deletions.
10 changes: 8 additions & 2 deletions hphp/hack/src/naming/naming.ml
Expand Up @@ -930,7 +930,10 @@ module Make (GetLocals : GetLocals) = struct
TypecheckerOptions.experimental_darray_and_varray in
if not darray_and_varray_allowed then Errors.darray_not_supported p;
Some (match hl with
| []
| [] ->
if (fst env).in_mode = FileInfo.Mstrict then
Errors.too_few_type_arguments p;
N.Hdarray ((p, N.Hany), (p, N.Hany))
| [_] -> Errors.too_few_type_arguments p; N.Hany
| [key_; val_] -> N.Hdarray (hint env key_, hint env val_)
| _ -> Errors.too_many_type_arguments p; N.Hany)
Expand All @@ -941,7 +944,10 @@ module Make (GetLocals : GetLocals) = struct
TypecheckerOptions.experimental_darray_and_varray in
if not darray_and_varray_allowed then Errors.varray_not_supported p;
Some (match hl with
| [] -> Errors.too_few_type_arguments p; N.Hany
| [] ->
if (fst env).in_mode = FileInfo.Mstrict then
Errors.too_few_type_arguments p;
N.Hvarray (p, N.Hany)
| [val_] -> N.Hvarray (hint env val_)
| _ -> Errors.too_many_type_arguments p; N.Hany)
| nm when nm = SN.Typehints.integer ->
Expand Down
@@ -0,0 +1,5 @@
<?hh

function test(): darray {
return darray[];
}
@@ -0,0 +1 @@
No errors
@@ -0,0 +1,5 @@
<?hh

function test(): varray {
return varray[0, 1, 2];
}
@@ -0,0 +1 @@
No errors
@@ -1,4 +1,4 @@
<?hh
<?hh // strict

function test(): darray {
return darray[];
Expand Down
@@ -1,4 +1,4 @@
<?hh
<?hh // strict

function test(): varray {
return varray[0, 1, 2];
Expand Down

0 comments on commit 6818d4c

Please sign in to comment.