}
static zend_always_inline void zend_ast_list_rtrim(zend_ast *ast) {
zend_ast_list *list = zend_ast_get_list(ast);
- while (list->children && list->child[list->children - 1] == NULL) {
+ if (list->children && list->child[list->children - 1] == NULL) {
list->children--;
}
}
static void zend_compile_unkeyed_list_assign(zend_ast_list *list, znode *expr_node, zend_bool old_style) /* {{{ */
{
uint32_t i;
-
- if (list->children == 0) {
- zend_error_noreturn(E_COMPILE_ERROR, "Cannot use empty list");
- }
+ zend_bool has_elems = 0;
for (i = 0; i < list->children; ++i) {
zend_ast *elem_ast = list->child[i];
}
var_ast = elem_ast->child[0];
+ has_elems = 1;
dim_node.op_type = IS_CONST;
ZVAL_LONG(&dim_node.u.constant, i);
zend_emit_op(&fetch_result, ZEND_FETCH_LIST, expr_node, &dim_node);
zend_emit_assign_znode(var_ast, &fetch_result);
}
+
+ if (has_elems == 0) {
+ zend_error_noreturn(E_COMPILE_ERROR, "Cannot use empty list");
+ }
+
}
/* }}} */