[php-src] Issue #7946: Rewrite zend_eval_const_expr to use a stack on the heap instead of recursion where possible?
| From: | TysonAndre | Date: | Sat, 15 Jan 2022 17:16:06 +0000 |
| Subject: | [php-src] Issue #7946: Rewrite zend_eval_const_expr to use a stack on the heap instead of recursion where possible? | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-239025@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/7946
Comment Author: TysonAndre
> That. The concat operator is likely the only binary operator where such super-deep nesting
> might happen otherwise.
I expect that to be the case in real-world usage, other kinds/flags would only show up in obscure
edge cases in fuzzing, or code generation/translation tools.
Changing expressions such as
a . b . c . d to a 4-value AST_CONCAT_LIST (min size 2)
seems straightforward, should be translatable to external projects such as php-parser (depending on
target php version?) and php-ast (new version number for parse_code/parse_file)
The output of token_get_all wouldn't change, so existing code wouldn't be affected
meaningfully. The line number of errors may need to be preserved for useful error messages for
users, but it's available on the child nodes (and the compiler may already use the line of the
child nodes, actually)
```php
$x = 'a' .
'b' .
new stdClass() .
'c';