-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support dynamic for splats in tuples
Summary: Tuple types of the form `(t, ...T)` support dynamic if `t` does and `T` does. Differential Revision: D66009281 fbshipit-source-id: e935d6252c1bc48f2fde2c83b2861444db7db18f
- Loading branch information
1 parent
a490802
commit b0df8ac
Showing
5 changed files
with
38 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
hphp/hack/test/typecheck/splat/tuple_splat_dynamic.bad.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?hh | ||
|
||
<<file: __EnableUnstableFeatures('open_tuples', 'type_splat')>> | ||
|
||
function expect_dyn(dynamic $_):void { } | ||
|
||
<<__NoAutoDynamic>> | ||
class C { } | ||
|
||
function test<<<__NoAutoBound>> T as (C...)>((int, ...T) $tup):void { | ||
expect_dyn($tup); | ||
} |
6 changes: 6 additions & 0 deletions
6
hphp/hack/test/typecheck/splat/tuple_splat_dynamic.bad.php.exp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
ERROR: File "tuple_splat_dynamic.bad.php", line 11, characters 14-17: | ||
Invalid argument (Typing[4110]) | ||
File "tuple_splat_dynamic.bad.php", line 5, characters 21-27: | ||
Expected `dynamic` | ||
File "tuple_splat_dynamic.bad.php", line 10, characters 46-56: | ||
Type `(int, ...T)` is not a subtype of `dynamic` under dynamic-aware subtyping |
12 changes: 12 additions & 0 deletions
12
hphp/hack/test/typecheck/splat/tuple_splat_dynamic.good.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?hh | ||
|
||
<<file: __EnableUnstableFeatures('open_tuples', 'type_splat')>> | ||
|
||
function expect_dyn(dynamic $_):void { } | ||
|
||
<<__SupportDynamicType>> | ||
class C { } | ||
|
||
function test<T as (C...)>((int, ...T) $tup):void { | ||
expect_dyn($tup); | ||
} |
1 change: 1 addition & 0 deletions
1
hphp/hack/test/typecheck/splat/tuple_splat_dynamic.good.php.exp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
No errors |