]> granicus.if.org Git - php/commitdiff
Ensure __LINE__ is always accurate
authorNikita Popov <nikic@php.net>
Sun, 12 Oct 2014 18:54:45 +0000 (20:54 +0200)
committerNikita Popov <nikic@php.net>
Sun, 12 Oct 2014 18:55:52 +0000 (20:55 +0200)
Zend/tests/line_const_in_array.phpt [new file with mode: 0644]
Zend/zend_compile.c

diff --git a/Zend/tests/line_const_in_array.phpt b/Zend/tests/line_const_in_array.phpt
new file mode 100644 (file)
index 0000000..181f67e
--- /dev/null
@@ -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)
+}
index e242bac951e99c7accb345b83345587bb3ba0a54..5d3ee24c84faa38c9192a514e0cbcd0ba867bb63 100644 (file)
@@ -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));