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
8 changes: 8 additions & 0 deletions Zend/tests/gh20113.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
--TEST--
GH-20113: First-class callable constructor in constant AST
--FILE--
<?php
const C = new \stdClass(...);
?>
--EXPECTF--
Fatal error: Cannot create Closure for new expression in %s on line %d
5 changes: 5 additions & 0 deletions Zend/zend_compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down