[GIT-PULLS] [php-src] PR #22833: Tweak lineno compilation
[email protected] (iluuu1994) Mon, 20 Jul 2026 15:24:20 +0000
| Newsgroups | php.git-pulls |
|---|---|
| Message-ID | <AvNJv57pTDePeRfrnHZDVhyuQkc42O6VcZb8En7x4bE@main.internal.php.net> |
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.