From c6900bba94a721534f4e67fc62ef611da1a5a679 Mon Sep 17 00:00:00 2001 From: Jan Oravec Date: Thu, 2 Oct 2014 18:57:27 -0700 Subject: [PATCH] Let hhbbc know that invariant_violation always fails Summary: hhbbc does not know about call_user_func_array(), so when invariant(condition(), ...); is rewritten as if (!condition()) { invariant(false, ...); } it has trouble figuring out that invariant(false, ...) never falls through. After this diff, hhbbc figures out correctly that invariant(false, ...) returns TBottom, but still cannot fully use this knowledge. Reviewed By: @ptarjan, @elgenie Differential Revision: D1595071 --- hphp/system/php/lang/invariant.ns.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/hphp/system/php/lang/invariant.ns.php b/hphp/system/php/lang/invariant.ns.php index a7da514c4d3..657679f0908 100644 --- a/hphp/system/php/lang/invariant.ns.php +++ b/hphp/system/php/lang/invariant.ns.php @@ -39,10 +39,9 @@ function invariant_callback_register(callable $callback) { * Ensure that an invariant is satisfied. If it fails, it calls * invariant_violation */ -function invariant(mixed $test, ...): void { +function invariant(mixed $test, ...$args): void { if (!$test) { - $args = \array_slice(\func_get_args(), 1); - \call_user_func_array('\HH\invariant_violation', $args); + \HH\invariant_violation(...$args); } } -- 2.11.4.GIT