diff --git a/NEWS b/NEWS index a9cf14a0635..3d0776c464f 100644 --- a/NEWS +++ b/NEWS @@ -2,11 +2,14 @@ PHP NEWS ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| ?? ??? ????, PHP 8.5.0RC3 +- Core: + . Fixed bug GH-20113 (Missing new Foo(...) error in constant expressions). + (ilutov) + - FPM: . Fixed bug GH-19817 (Decode SCRIPT_FILENAME issue in php 8.5). (Jakub Zelenka) - - SPL: . Fixed bug GH-20101 (SplHeap/SplPriorityQueue serialization exposes INDIRECTs). (nielsdos) diff --git a/Zend/tests/gh20113.phpt b/Zend/tests/gh20113.phpt new file mode 100644 index 00000000000..64e029a6cec --- /dev/null +++ b/Zend/tests/gh20113.phpt @@ -0,0 +1,8 @@ +--TEST-- +GH-20113: new Foo(...) error in constant expressions +--FILE-- + +--EXPECTF-- +Fatal error: Cannot create Closure for new expression in %s on line %d diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index a5878317861..8d6ca5a6434 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -11468,6 +11468,11 @@ static void zend_compile_const_expr_new(zend_ast **ast_ptr) { zend_ast *class_ast = (*ast_ptr)->child[0]; zend_compile_const_expr_class_reference(class_ast); + + zend_ast *args_ast = (*ast_ptr)->child[1]; + if (args_ast->kind == ZEND_AST_CALLABLE_CONVERT) { + zend_error_noreturn(E_COMPILE_ERROR, "Cannot create Closure for new expression"); + } } static void zend_compile_const_expr_closure(zend_ast **ast_ptr)