summaryrefslogtreecommitdiff
path: root/Zend/zend_compile.c
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2019-01-02 11:32:48 +0100
committerNikita Popov <nikita.ppv@gmail.com>2019-01-02 11:32:48 +0100
commit73596c56e7905ce5b7c4f15d551361ee744cad0c (patch)
treeb9fe5a103d197263963550666755831bad14cfde /Zend/zend_compile.c
parent7b3f8e746af83b044ff86c0d864801929b1dd1d9 (diff)
downloadphp-git-73596c56e7905ce5b7c4f15d551361ee744cad0c.tar.gz
Partial fix for bug #75426
This does not print the exact line of the comma, but rather the line of the previous element. This should generally be "good enough", as the line number is close (off by one) to the actual issue now. Previously it would point to the start of the array, which may be very far away.
Diffstat (limited to 'Zend/zend_compile.c')
-rw-r--r--Zend/zend_compile.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c
index 77702b3fac..23c3b99968 100644
--- a/Zend/zend_compile.c
+++ b/Zend/zend_compile.c
@@ -6920,6 +6920,7 @@ static inline void zend_ct_eval_greater(zval *result, zend_ast_kind kind, zval *
static zend_bool zend_try_ct_eval_array(zval *result, zend_ast *ast) /* {{{ */
{
zend_ast_list *list = zend_ast_get_list(ast);
+ zend_ast *last_elem_ast = NULL;
uint32_t i;
zend_bool is_constant = 1;
@@ -6932,6 +6933,10 @@ static zend_bool zend_try_ct_eval_array(zval *result, zend_ast *ast) /* {{{ */
zend_ast *elem_ast = list->child[i];
if (elem_ast == NULL) {
+ /* Report error at line of last non-empty element */
+ if (last_elem_ast) {
+ CG(zend_lineno) = zend_ast_get_lineno(last_elem_ast);
+ }
zend_error(E_COMPILE_ERROR, "Cannot use empty array elements in arrays");
}
@@ -6943,6 +6948,8 @@ static zend_bool zend_try_ct_eval_array(zval *result, zend_ast *ast) /* {{{ */
) {
is_constant = 0;
}
+
+ last_elem_ast = elem_ast;
}
if (!is_constant) {