@@ -3944,13 +3944,18 @@ static void zend_compile_assert(znode *result, zend_ast_list *args, zend_string
3944
3944
}
3945
3945
opline -> result .num = zend_alloc_cache_slot ();
3946
3946
3947
- if (args -> children == 1 &&
3948
- (args -> child [0 ]-> kind != ZEND_AST_ZVAL ||
3949
- Z_TYPE_P (zend_ast_get_zval (args -> child [0 ])) != IS_STRING )) {
3947
+ if (args -> children == 1 ) {
3950
3948
/* add "assert(condition) as assertion message */
3951
- zend_ast_list_add ((zend_ast * )args ,
3952
- zend_ast_create_zval_from_str (
3953
- zend_ast_export ("assert(" , args -> child [0 ], ")" )));
3949
+ zend_ast * arg = zend_ast_create_zval_from_str (
3950
+ zend_ast_export ("assert(" , args -> child [0 ], ")" ));
3951
+ if (args -> child [0 ]-> kind == ZEND_AST_NAMED_ARG ) {
3952
+ /* If the original argument was named, add the new argument as named as well,
3953
+ * as mixing named and positional is not allowed. */
3954
+ zend_ast * name = zend_ast_create_zval_from_str (
3955
+ zend_string_init ("description" , sizeof ("description" ) - 1 , 0 ));
3956
+ arg = zend_ast_create (ZEND_AST_NAMED_ARG , name , arg );
3957
+ }
3958
+ zend_ast_list_add ((zend_ast * ) args , arg );
3954
3959
}
3955
3960
3956
3961
zend_compile_call_common (result , (zend_ast * )args , fbc );
0 commit comments