[php-src] PR #22833: Tweak lineno compilation
| From: | iluuu1994 | Date: | Mon, 20 Jul 2026 15:24:20 +0000 |
| Subject: | [php-src] PR #22833: Tweak lineno compilation | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-37197@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/22833
Author: iluuu1994
zend_compile_expr() and zend_compile_var() now restore CG(zend_lineno) after compilation of the node
has finished. This makes the compiled lineno more predictable.
Fixes GH-18985
Note that there are many cases left that are incorrect. For example:
```php
<?php
return
foo();
```
```
L0004 0000 INIT_FCALL_BY_NAME 0 string("foo")
L0004 0001 T0 = DO_FCALL_BY_NAME
L0004 0002 RETURN T0
L0007 0003 RETURN int(1)
```
zend_ast_create_1() set lineno to the lineno of the first
available child. In this case that's foo(), even though it's not on the same
line as return. What we'd need instead is backing up CG(zend_lineno)
after the return keyword in the parser so we can restore it later. However, this would
be a rather invasive change, given the same issue exists for many ast kinds, so a better solution
might just be to re-commit e528762c1c59bc0bd0bd6d78246c14269630cf0f.
I don't feel comfortable backporting this as a bug fix, but we might address the issue in a
simpler, less comprehensive manner for older branches.