Skip to content

Commit 711020e

Browse files
committed
zend_compile: Pass the clone property list to the ZEND_CLONE OPcode
1 parent cd7fcc1 commit 711020e

File tree

1 file changed

+44
-1
lines changed

1 file changed

+44
-1
lines changed

Zend/zend_compile.c

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5404,7 +5404,50 @@ static void zend_compile_clone(znode *result, zend_ast *ast) /* {{{ */
54045404
znode obj_node;
54055405
zend_compile_expr(&obj_node, obj_ast);
54065406

5407-
zend_emit_op_tmp(result, ZEND_CLONE, &obj_node, NULL);
5407+
znode value_node;
5408+
if (ast->child[1]) {
5409+
ZEND_ASSERT(ast->child[1]->kind == ZEND_AST_ARG_LIST);
5410+
zend_ast_list *args_ast = zend_ast_get_list(ast->child[1]);
5411+
ZEND_ASSERT(args_ast->children > 0);
5412+
5413+
zend_ast *array;
5414+
zend_ast *last;
5415+
5416+
for (uint32_t i = 0; i < args_ast->children; ++i) {
5417+
zend_ast *arg = args_ast->child[i];
5418+
5419+
switch (arg->kind) {
5420+
case ZEND_AST_UNPACK:
5421+
if (args_ast->children != 1) {
5422+
zend_error_noreturn(E_COMPILE_ERROR, "Cannot combine unpacking with other arguments");
5423+
}
5424+
5425+
array = arg->child[0];
5426+
5427+
break;
5428+
case ZEND_AST_NAMED_ARG: {
5429+
zend_ast *elem = zend_ast_create(ZEND_AST_ARRAY_ELEM, arg->child[1], arg->child[0]);
5430+
if (i == 0) {
5431+
array = zend_ast_create_list(args_ast->children, ZEND_AST_ARRAY, elem);
5432+
last = array;
5433+
} else {
5434+
last = zend_ast_list_add(last, elem);
5435+
}
5436+
break;
5437+
}
5438+
default:
5439+
zend_error_noreturn(E_COMPILE_ERROR, "Cannot use unnamed argument");
5440+
break;
5441+
}
5442+
}
5443+
5444+
zend_compile_expr(&value_node, array);
5445+
} else {
5446+
value_node.op_type = IS_UNUSED;
5447+
}
5448+
5449+
5450+
zend_emit_op_tmp(result, ZEND_CLONE, &obj_node, &value_node);
54085451
}
54095452
/* }}} */
54105453

0 commit comments

Comments
 (0)