diff options
| author | Nikita Popov <nikic@php.net> | 2014-10-12 20:54:45 +0200 |
|---|---|---|
| committer | Nikita Popov <nikic@php.net> | 2014-10-12 20:55:52 +0200 |
| commit | 0b09ba84b912be90c06d8d5ffab55bf850c3070b (patch) | |
| tree | b68a9980b0cc328f0db6a1d3eae283fcd2a0133f | |
| parent | b7e139a59ca7962c98ce1eb75150dd131978b41d (diff) | |
| download | php-git-0b09ba84b912be90c06d8d5ffab55bf850c3070b.tar.gz | |
Ensure __LINE__ is always accurate
| -rw-r--r-- | Zend/tests/line_const_in_array.phpt | 21 | ||||
| -rw-r--r-- | Zend/zend_compile.c | 2 |
2 files changed, 22 insertions, 1 deletions
diff --git a/Zend/tests/line_const_in_array.phpt b/Zend/tests/line_const_in_array.phpt new file mode 100644 index 0000000000..181f67e3da --- /dev/null +++ b/Zend/tests/line_const_in_array.phpt @@ -0,0 +1,21 @@ +--TEST-- +Use of __LINE__ in arrays +--FILE-- +<?php + +var_dump([ + __LINE__, + __LINE__, + __LINE__, +]); + +?> +--EXPECT-- +array(3) { + [0]=> + int(4) + [1]=> + int(5) + [2]=> + int(6) +} diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index e242bac951..5d3ee24c84 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -4917,7 +4917,7 @@ static zend_bool zend_try_ct_eval_magic_const(zval *zv, zend_ast *ast TSRMLS_DC) switch (ast->attr) { case T_LINE: - ZVAL_LONG(zv, CG(zend_lineno)); + ZVAL_LONG(zv, ast->lineno); break; case T_FILE: ZVAL_STR_COPY(zv, CG(compiled_filename)); |
