Repository navigation
fix: pin the int-for-float checker and keep the folded negative power under test - #100
Merged
Merged
Conversation
… under test Problem - mago-sharp #129 now reads the exponent's type, so `let b = -1; 2 ** b` is refused at compile time. `Overflow::constantNegativePower` and `Overflow::zeroNegativePower` held their exponent that way to make opcache fold a constant negative power. Under the new pin they no longer compile, and the proof of the `zend_binary_op_produces_error` guard would be lost with them. - docs/spec.md annotates the int-for-float rule with "write 0.0, or convert with (float) n" and "same message". The checker prints one fix, by the one reason the value was refused. Solution - Hold the exponent as `~0`. The checker types `~0` as plain `int`, and opcache SCCP still folds it to `int(-1)`, so the dump shows `POW int(2) int(-1)` and `POW int(0) int(-1)` as before. Without the three guard lines, overflow_pow.phpt fails under `sharp/bin/test --passes` in both JIT modes with "Deprecated: Power of base 0 and negative exponent is deprecated". With them, all 22 modes pass on the three overflow_pow*.phpt tests. - Each spec annotation of the rule prints the exact message the checker prints. - Pin SHARP_MAGO_COMMIT to mago-sharp #129's head. The header that commit generates differs from this one only in the pin. Zend/tests/sharp/ Overflow.sharp constantNegativePower and zeroNegativePower hold -1 as ~0 docs/ spec.md the int-for-float annotations print the checker's message ext/sharp/ sharp_unit.h SHARP_MAGO_COMMIT bce91aa
Problem - master took #101, which pins Mago at #118 (90e8d64) and rewrites Sets.sharp:75 and Sets.inc:75 so a Set's changing method has a place. - This branch pinned #129's head (bce91aa). Both sides changed the pin line. #129 merged as 82593a4, which did not compile, and mago-sharp #153 fixed it as 625c278. Solution - Take master's Sets.sharp and Sets.inc as they are. - SHARP_MAGO_COMMIT pins 625c278, the merge of #153, which carries both #118 and #129. The bridge sources the header is generated from are unchanged since bce91aa, so the pin is the only line the generated header changes. Zend/tests/sharp/ Sets.sharp, Sets.inc from master: the copied Set is held in a local before add ext/sharp/ sharp_unit.h conflict: SHARP_MAGO_COMMIT is 625c278, the merge of mago-sharp #153
Problem - Decision 73 quotes the int-for-float error as "`int` is not `float`: write 0.0, or convert with (float) n", and says "same message" for `count` and `cell.put(2)`. The checker now prints one fix, for the code written, and spec section 24 already quotes it. Solution - The decision says the error quotes the one fix for the code written, with `0` and `count` as examples, and its annotations print the messages spec section 24 prints. docs/decisions/ 073-int-to-float.md lines 5, 12, 14 and 17 print the checker's message
heyJordanParker
added a commit
that referenced
this pull request
Oct 11, 2026
… to Mago 9cb1a28 Problem: Master gained #100, which pins Mago #129 and keeps `Overflow.constantNegativePower` and `Overflow.zeroNegativePower` compiling under #129's negative-power refusal by writing each exponent as `~0`. This branch had fixed the same two lines with `int b = -1;` and `int n = -1;`, so `Overflow.sharp` and the pin in `ext/sharp/sharp_unit.h` conflicted. Solution: - `Overflow.sharp` takes master's `~0`, which owns the fix. This branch's typed locals are gone. - `ext/sharp/sharp_unit.h` is the header Mago 9cb1a28 generates. `php -n --ri sharp` prints "Mago commit => 9cb1a28…". - `sharp/bin/test` passes 202 of 202 tests, and `sharp/bin/test --passes Zend/tests/sharp/overflow_pow.phpt` passes in all 19 modes. Zend/tests/sharp/Overflow.sharp <- conflict: master's `~0` ext/sharp/sharp_unit.h <- conflict: pinned to Mago 9cb1a28
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
heyJordanParker/mago-sharp#129 refuses an
intwhere PHP# expects afloat. It also reads the type of a**exponent, solet b = -1; return 2 ** b;is refused at compile time.Overflow::constantNegativePowerandOverflow::zeroNegativePowerheld their exponent that way. That form made opcache fold a constant negative power, which is what proves thezend_binary_op_produces_errorguard from #97. Under the new pin the two methods no longer compile.docs/spec.mdsection 24 annotated the rule with "write 0.0, or convert with (float) n" and "same message". The checker prints one fix, chosen by the code written.Solution
SHARP_MAGO_COMMITpins 625c278, the merge of mago-sharp #153. It carries #129 and #118. #129 merged as 82593a4, which did not compile against #118, and #153 fixed that. The bridge sources the header is generated from are unchanged since #129's head bce91aa, whose generated header differs from this one only in the pin.The branch merges master after #101, which pins #118 and holds
Sets.sharp's copiedSetin a local beforeadd. ItsSets.sharpandSets.incare taken as they are.The two methods hold the exponent as
~0. The checker types~0as plainint, and opcache still propagates it as the constantint(-1):Each section 24 annotation of the rule now prints the message the checker prints:
Decision 73 quoted the same old message on lines 5, 12, 14 and 17. It now says the error quotes the one fix for the code written, and its annotations print the lines above.
Verification
The fold guard still has a test that fails without it:
zend_binary_op_produces_errorremoved,sharp/bin/test --passes Zend/tests/sharp/overflow_pow.phptfails under the tracing JIT and the function JIT. Each prints the extra lineDeprecated: Power of base 0 and negative exponent is deprecated in .../overflow_pow.inc on line 7.sharp/bin/test --opcache --repeat --passesonoverflow_pow.phpt,overflow_pow_jit_function.phptandoverflow_pow_jit_tracing.phptpasses in all 22 modes.At the final pin, 625c278:
php -n --ri sharpprintsMago commit => 625c278f8303ff004daa00d29a9a90ca4e56fd6c.mago compileat that commit compiles all 99 PHP# fixtures.sharp/bin/test --opcache --repeat --passeson the threeoverflow_pow*.phptand the threeset_methods*.phpttests passes 6 of 6 in all 22 modes.sharp/bin/testpasses 171 of 171.Files