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

Add (void) cast #18115

Merged
merged 2 commits into from
Mar 24, 2025
Merged

Add (void) cast #18115

merged 2 commits into from
Mar 24, 2025

Conversation

TimWolla
Copy link
Member

RFC: https://wiki.php.net/rfc/marking_return_value_as_important

Spun out of #17599, since the (void) cast implementation is fully independent of the #[\NoDiscard] implementation and sufficiently complex on its own, allowing for an easier review.

@TimWolla TimWolla requested a review from nielsdos March 21, 2025 08:22
zend_op *opline;

zend_do_extended_fcall_begin();
zend_compile_expr(&expr_node, expr_ast);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess you could optimize it a bit by not even handling IS_CONSTANT_AST in the first place, i.e. early returning.
I would still keep the IS_CONST handling below though because it generalises.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As with the (void)(bool) cast, this feels like needless added complexity for a case that is unlikely to happen in practice and also no longer matters once the file is compiled and OPcached.

Copy link
Member

@iluuu1994 iluuu1994 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is missing support for AST printing in zend_ast.c.

LGTM otherwise.

@nielsdos nielsdos merged commit 0e95233 into php:master Mar 24, 2025
9 checks passed
@TimWolla TimWolla deleted the void-cast branch March 24, 2025 18:44
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.

3 participants