Skip to content

Commit f9208e9

Browse files
committed
Merge branch 'PHP-7.3'
2 parents d64b748 + 6136835 commit f9208e9

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

Zend/tests/bug75426.phpt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
--TEST--
2+
Bug #75426: "Cannot use empty array elements" reports wrong position
3+
--FILE--
4+
<?php
5+
$a = [
6+
1,
7+
2,
8+
3,
9+
,
10+
5,
11+
6,
12+
];
13+
?>
14+
--EXPECTF--
15+
Fatal error: Cannot use empty array elements in arrays in %s on line 5

Zend/zend_compile.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6911,6 +6911,7 @@ static inline void zend_ct_eval_greater(zval *result, zend_ast_kind kind, zval *
69116911
static zend_bool zend_try_ct_eval_array(zval *result, zend_ast *ast) /* {{{ */
69126912
{
69136913
zend_ast_list *list = zend_ast_get_list(ast);
6914+
zend_ast *last_elem_ast = NULL;
69146915
uint32_t i;
69156916
zend_bool is_constant = 1;
69166917

@@ -6923,6 +6924,10 @@ static zend_bool zend_try_ct_eval_array(zval *result, zend_ast *ast) /* {{{ */
69236924
zend_ast *elem_ast = list->child[i];
69246925

69256926
if (elem_ast == NULL) {
6927+
/* Report error at line of last non-empty element */
6928+
if (last_elem_ast) {
6929+
CG(zend_lineno) = zend_ast_get_lineno(last_elem_ast);
6930+
}
69266931
zend_error(E_COMPILE_ERROR, "Cannot use empty array elements in arrays");
69276932
}
69286933

@@ -6934,6 +6939,8 @@ static zend_bool zend_try_ct_eval_array(zval *result, zend_ast *ast) /* {{{ */
69346939
) {
69356940
is_constant = 0;
69366941
}
6942+
6943+
last_elem_ast = elem_ast;
69376944
}
69386945

69396946
if (!is_constant) {

0 commit comments

Comments
 (0)