Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions Zend/tests/throw/throw_throw_throw.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
--TEST--
throw throw guard
--FILE--
<?php

try {
throw throw new Exception;
} catch (Exception $e) {
}
?>
--EXPECTF--
Fatal error: Cannot throw throw expression in %s on line %d
4 changes: 4 additions & 0 deletions Zend/zend_compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down