diff --git a/Zend/tests/throw/throw_throw_throw.phpt b/Zend/tests/throw/throw_throw_throw.phpt new file mode 100644 index 0000000000000..c4d765acc9f7f --- /dev/null +++ b/Zend/tests/throw/throw_throw_throw.phpt @@ -0,0 +1,12 @@ +--TEST-- +throw throw guard +--FILE-- + +--EXPECTF-- +Fatal error: Cannot throw throw expression in %s on line %d \ No newline at end of file diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index cb64729806a23..2bdcb87b2d012 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -5746,6 +5746,10 @@ static void zend_compile_throw(znode *result, zend_ast *ast) /* {{{ */ { zend_ast *expr_ast = ast->child[0]; + if (expr_ast->kind == ZEND_AST_THROW) { + zend_error_noreturn(E_COMPILE_ERROR, "Cannot throw throw expression"); + } + znode expr_node; zend_compile_expr(&expr_node, expr_ast);