Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preserve the original AST for closures in const-expressions #17120

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

TimWolla
Copy link
Member

Fixes GH-17096.

@iluuu1994
Copy link
Member

Tbh, I would prefer a simple solution, e.g. by printing a placeholder in the ast dumper. Accurate ast dumping is not very important.

@TimWolla
Copy link
Member Author

That would also be fine with me.

Nevertheless I would suggest to keep the first commit (I can send a separate PR for that), as it it definitely fixes a bug in handling of zend_ast_decl nodes that is not (easily) detectable with sanitizers. It will just work on garbage values.

@mvorisek

This comment was marked as off-topic.

Previously `zend_ast_decl` AST nodes were handled as if they were regular
`zend_ast` nodes.

This was not observable, because copying an AST only happened when evaluating
const-expressions, which could not include declarations until the “Support
Closures in constant expressions” RFC.
This is necessary when stringifying a `ReflectionAttribute` that has a closure
as a parameter.
@TimWolla TimWolla force-pushed the ast-op-array-original-ast branch from 05e868f to 45057db Compare December 11, 2024 12:55
@bwoebi
Copy link
Member

bwoebi commented Dec 12, 2024

@iluuu1994 I actually like the full AST being there. While it's not fundamentally necessary for usability, it's nice to have I think.

@iluuu1994
Copy link
Member

One difference imo is that closures may grow large, in comparison to singular expressions. This ast is almost never used, but will still take up shm space with little benefit.

@bwoebi
Copy link
Member

bwoebi commented Dec 12, 2024

@iluuu1994 I doubt the amount of closures within attributes will be significant enough to warrant considerations in that regard.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SIGABRT/SIGTRAP when using closures in attributes in PHP 8.5
4 participants