Skip to content

chore: pin Mago at #118, where a Set's changing methods need a place - #101

Merged
heyJordanParker merged 1 commit into
masterfrom
fix/pin-set-changes
Oct 11, 2026
Merged

heyJordanParker merged 1 commit into
masterfrom
fix/pin-set-changes

Conversation

@heyJordanParker

Copy link
Copy Markdown
Owner

Problem

mago-sharp #118 (merged as 90e8d64) makes a PHP# Set's add, remove and clear need a place to write back to, as a List's and a Map's changing methods do. Zend/tests/sharp/Sets.sharp line 75 called this.copy().add("copy") on a method's result, so mago compile at #118 refuses Sets.sharp, and the engine runs only compiled files.

Solution

SHARP_MAGO_COMMIT in ext/sharp/sharp_unit.h moves to 90e8d64.

Sets.sharp stores the copy in a local and changes it there:

-        const copied = this.copy().add("copy");
+        let copy = this.copy();
+        const copied = copy.add("copy");

copied still holds add's result, so the three set_methods*.phpt tests print the same output. Its PHP twin Sets.inc changes the same way, line for line, so opcodes.phpt still finds the same opcodes and lines. The .phpt files cite only lines 18 and 43, which do not move.

Verification

  • The header mago-sharp-bridge generates from 90e8d64's tree differs from ext/sharp/sharp_unit.h only in SHARP_MAGO_COMMIT.
  • php -n --ri sharp prints Mago commit => 90e8d64ee4f056e3acb7d2d252062627aa223eb0.
  • sharp/bin/test --opcache --repeat --passes on the three set_methods*.phpt files and opcodes.phpt passes 4 of 4 in all 22 modes. mago compile at the pin compiles 99 fixtures and refuses none.
  • sharp/bin/test passes 171 of 171.
ext/sharp/sharp_unit.h        <- SHARP_MAGO_COMMIT 90e8d64ee
Zend/tests/sharp/
├── Sets.sharp                <- the copy changed through a local
└── Sets.inc                  <- its PHP twin, line for line

Problem:
mago-sharp #118 (90e8d64) makes a PHP# Set's add, remove and clear need a
place to write back to, as a List's and a Map's changing methods do. The
fixture Zend/tests/sharp/Sets.sharp called this.copy().add("copy") on a
method's result, so mago compile at #118 refuses Sets.sharp, and the
engine runs only compiled files.

Solution:
- SHARP_MAGO_COMMIT in ext/sharp/sharp_unit.h moves to 90e8d64. The
  header the bridge generates at that tree differs from this one only in
  that line.
- Sets.sharp stores the copy in a local, let copy = this.copy();, and calls
  copy.add("copy") on it, so copied still holds add's result and the set
  tests print the same output. Its PHP twin Sets.inc changes the same way,
  line for line, so opcodes.phpt still finds the same opcodes and lines.

ext/sharp/sharp_unit.h        <- SHARP_MAGO_COMMIT 90e8d64
Zend/tests/sharp/
├── Sets.sharp                <- the copy changed through a local
└── Sets.inc                  <- its PHP twin, line for line
@heyJordanParker
heyJordanParker merged commit cf3de97 into master Oct 11, 2026
9 checks passed
@heyJordanParker
heyJordanParker deleted the fix/pin-set-changes branch October 11, 2026 19:44
heyJordanParker added a commit that referenced this pull request Oct 11, 2026
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
heyJordanParker added a commit that referenced this pull request Oct 11, 2026
… to Mago fe442e9

Problem:
Master gained #101, which pins Mago 90e8d64 and rewrites `Sets.sharp:75` so a `Set` that
`copy()` returns is added to through a local. This branch had made the same fix on one line,
so `Sets.sharp`, `Sets.inc` and the pin in `ext/sharp/sharp_unit.h` conflicted.

The generics Mago branch now also holds Mago #129, which refuses an `int` raised to a
negative power the checker knows. Its flow typing knows `let b = -1;`, so it refuses
`Overflow.constantNegativePower` and `Overflow.zeroNegativePower`, the two fixtures that test
the engine's `ArithmeticError` when opcache propagates a negative exponent. Every pin that
holds #129 refuses them, on master too.

Solution:
- `Sets.sharp` and `Sets.inc` take master's two-line fix, which owns it.
- `ext/sharp/sharp_unit.h` is the header Mago fe442e9 generates.
- `Overflow.sharp` declares each exponent `int b = -1;` and `int n = -1;`. The checker then
  knows only `int`, and opcache still propagates the constant: the optimized
  `Overflow::constantNegativePower` is `T0 = POW int(2) int(-1)`, which throws. Each line
  keeps its line number. `sharp/bin/test --passes Zend/tests/sharp/overflow_pow.phpt` passes
  under every optimizer pass alone and both JITs.

Zend/tests/sharp/
├── Sets.sharp, Sets.inc   <- conflict: master's fix
└── Overflow.sharp         <- the two negative exponents are typed int locals
ext/sharp/sharp_unit.h     <- conflict: pinned to Mago fe442e9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant