Skip to content

ext/gmp: Fix some issues regarding operator overloading #16015

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

Closed
wants to merge 11 commits into from

Conversation

Girgias
Copy link
Member

@Girgias Girgias commented Sep 23, 2024

Related to #15660

The behaviour of the engine in regards to operator overloading atm is kinda bonkers and needs some deeper fixes.

The implementation of operator overloading in GMP also needs an overhaul as it should return FAILURE instead of throwing exceptions if it cannot handle the operands.

@Girgias Girgias force-pushed the gmp-8.2-null-op-overloading branch from 861caf5 to fadd51d Compare September 23, 2024 22:25
@Girgias Girgias marked this pull request as ready for review September 24, 2024 10:53
@Girgias Girgias requested review from cmb69 and nielsdos September 24, 2024 10:54
if (UNEXPECTED(!IS_GMP(op2))) {
goto typeof_op_failure;
} else {
// TODO We shouldn't cast the GMP object to int here
Copy link
Member

Choose a reason for hiding this comment

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

Amazing

@cmb69
Copy link
Member

cmb69 commented Sep 25, 2024

Isn't this too large a BC break for targeting PHP-8.2? Some operators now behave stricter than calling the functions in coercive typing mode (see e.g. https://3v4l.org/nQkCK).

@nielsdos
Copy link
Member

For safety best merge this in 8.4 and up then?

@Girgias
Copy link
Member Author

Girgias commented Sep 25, 2024

Isn't this too large a BC break for targeting PHP-8.2? Some operators now behave stricter than calling the functions in coercive typing mode (see e.g. https://3v4l.org/nQkCK).

Okay, let me see if I can handle the string case.

@Girgias
Copy link
Member Author

Girgias commented Sep 25, 2024

Right I remember part of it... 8.2 doesn't have the zend_try_get_long() API, as that is only exposed in 8.3. :[

@Girgias Girgias force-pushed the gmp-8.2-null-op-overloading branch from 6f8c6e8 to be6bded Compare October 25, 2024 20:50
@Girgias
Copy link
Member Author

Girgias commented Oct 25, 2024

@cmb69 hopefully I've covered all the cases now.

Copy link
Member

@cmb69 cmb69 left a comment

Choose a reason for hiding this comment

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

I guess this is as good as it goes. Thank you!

I haven't checked closely, though, since I'm still more concerned about mpir on Windows generally. Maybe @devnexen and/or @nielsdos want to review this PR.

Copy link
Member

@nielsdos nielsdos 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 gonna be as good as it's gonna get.
Note that I'm not convinced of your UNEXPECTED macro usage. UNEXPECTED actively penalizes code by moving it to the cold section, this is different than doing e.g. !EXPECTED. I try to use the UNEXPECTED macro only on error cases. Anyway, it's not that big of a deal.

Copy link
Member

@devnexen devnexen left a comment

Choose a reason for hiding this comment

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

MSTM

@Girgias Girgias closed this in 5253647 Nov 2, 2024
@Girgias Girgias deleted the gmp-8.2-null-op-overloading branch November 2, 2024 17:42
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.

4 participants