Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Fix as-expression irgen for vec/dict
Summary: We didn't bail early for as-expressions when checking for vec/dict in irgen, leading us to emit an is-expression instead of an as-expression. Reviewed By: oulgen Differential Revision: D8708371 fbshipit-source-id: e7212873d91f09f7b3783a78a1510dd2a72b42b2
- Loading branch information
Showing
with
63 additions
and 0 deletions.
@@ -0,0 +1,20 @@ | ||
<?hh | ||
|
||
function f(mixed $x): void { | ||
try { | ||
var_dump($x as dict); | ||
} catch (TypeAssertionException $_) { | ||
echo "not dict: ".gettype($x)."\n"; | ||
} | ||
} | ||
|
||
f(1); | ||
f(false); | ||
f(1.5); | ||
f('foo'); | ||
f(STDIN); | ||
f(new stdClass()); | ||
f(vec[]); | ||
f(dict[]); | ||
f(keyset[]); | ||
f(null); |
@@ -0,0 +1,11 @@ | ||
not dict: integer | ||
not dict: boolean | ||
not dict: double | ||
not dict: string | ||
not dict: resource | ||
not dict: object | ||
not dict: vec | ||
dict(0) { | ||
} | ||
not dict: keyset | ||
not dict: NULL |
@@ -0,0 +1,20 @@ | ||
<?hh | ||
|
||
function f(mixed $x): void { | ||
try { | ||
var_dump($x as vec); | ||
} catch (TypeAssertionException $_) { | ||
echo "not vec: ".gettype($x)."\n"; | ||
} | ||
} | ||
|
||
f(1); | ||
f(false); | ||
f(1.5); | ||
f('foo'); | ||
f(STDIN); | ||
f(new stdClass()); | ||
f(vec[]); | ||
f(dict[]); | ||
f(keyset[]); | ||
f(null); |
@@ -0,0 +1,11 @@ | ||
not vec: integer | ||
not vec: boolean | ||
not vec: double | ||
not vec: string | ||
not vec: resource | ||
not vec: object | ||
vec(0) { | ||
} | ||
not vec: dict | ||
not vec: keyset | ||
not vec: NULL |