-
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.
Enforce like types in type hint positions
Summary: As part of the spec for sound dynamic, we said we want `~T` to enforce as `T`, a departure from our original approach which had it enforce as mixed (but as D40516837 (9e8c173) shows, wasn't happening for reified generics). This way, changing a declaration from `int` to `~int` doesn't cause the code to lose enforcement. The "enforce as mixed" idea came to mind from trying to replace `mixed/dynamic` with like types, but we're introducing TANY_MARKER to deal with those. Reviewed By: andrewjkennedy Differential Revision: D40516838 fbshipit-source-id: ec2f0b16edb0398af541ece1f181dd9c4a3ad49b
- Loading branch information
1 parent
201e947
commit ad1dbd1
Showing
17 changed files
with
117 additions
and
18 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
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
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
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 |
---|---|---|
@@ -1,18 +1,32 @@ | ||
int(1) | ||
|
||
Warning: Value returned from async function f() must be of type @int, float given in %s/test/slow/like_types/awaitable2.php on line 7 | ||
float(1.5) | ||
|
||
Warning: Value returned from async function f() must be of type @int, string given in %s/test/slow/like_types/awaitable2.php on line 7 | ||
string(3) "foo" | ||
|
||
Warning: Value returned from async function f() must be of type @int, bool given in %s/test/slow/like_types/awaitable2.php on line 7 | ||
bool(false) | ||
resource(%d) of type (stream) | ||
|
||
Warning: Value returned from async function f() must be of type @int, File given in %s/test/slow/like_types/awaitable2.php on line 7 | ||
resource(4) of type (stream) | ||
|
||
Warning: Value returned from async function f() must be of type @int, stdClass given in %s/test/slow/like_types/awaitable2.php on line 7 | ||
object(stdClass) (0) { | ||
} | ||
|
||
Warning: Value returned from async function f() must be of type @int, HH\vec given in %s/test/slow/like_types/awaitable2.php on line 7 | ||
vec(3) { | ||
int(1) | ||
int(2) | ||
int(3) | ||
} | ||
|
||
Warning: Value returned from async function f() must be of type @int, HH\dict given in %s/test/slow/like_types/awaitable2.php on line 7 | ||
dict(2) { | ||
["a"]=> | ||
int(1) | ||
["b"]=> | ||
int(2) | ||
} | ||
} |
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
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
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
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
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
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
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
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
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
<?hh | ||
|
||
function f(mixed $x): ~int { | ||
function f(mixed $x): <<__Soft>> ~int { | ||
return $x; | ||
} | ||
|
||
|
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
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
<?hh | ||
|
||
function f(mixed $x): MyAlias { | ||
function f(mixed $x): <<__Soft>> MyAlias { | ||
return $x; | ||
} | ||
|
||
|
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
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