Skip to content

Test: differential sweep against Zend (#23354) - #23444

Merged
PurHur merged 1 commit into
masterfrom
tools/differential-sweep
Jul 26, 2026
Merged

Test: differential sweep against Zend (#23354)#23444
PurHur merged 1 commit into
masterfrom
tools/differential-sweep

Conversation

@PurHur

@PurHur PurHur commented Jul 26, 2026

Copy link
Copy Markdown
Owner

Adds the harness that found #23354, as a reusable gate.

The compliance suite asserts against recorded expectations, so it catches only what someone already thought to record. Nothing in the tree compared compiler output against Zend on arbitrary programs — which is why multi-argument calls handing every argument the trailing one's value survived undetected:

f($x + 1, $x + 2);                          // Zend "11 12"  → phpc "12 12"
str_replace($p['from'], $p['to'], 'xy!');   // Zend "zw!"    → phpc "xy!"

Both run to completion and print the wrong thing. No warning, no error, no failing test.

24 of these 43 programs mismatched Zend on master when the corpus was written. All are fixed (#23356, #23424); the corpus stays as the regression guard.

script/differential-sweep.sh              # VM backend  → 43/43 match
script/differential-sweep.sh --aot        # AOT backend
script/differential-sweep.sh --dir DIR    # any directory of programs

Exit status is the mismatch count, so it can gate a build.

Cases are deliberately mundane, because that is where silent wrong output hides: multi-argument calls by producer kind; mixed producer kinds in one call (where positional heuristics break); and the shapes the argument-resolution heuristics were individually tuned against — var_export, usort, in_array/array_search, array_merge, array_slice, array_pad, sprintf, str_replace, substr, by-ref params, named args, spread, closures/arrow fns, static calls, constructor promotion.

The README documents the one hard rule for new cases: they must be deterministic. hrtime() is the live counter-example (#23443) — it is not monotonic here, so any case using it flips between runs and poisons regression comparisons.

The compliance suite asserts against recorded expectations, so it only catches
what someone already thought to record. Nothing in the tree compared the
compiler's output against Zend's on arbitrary programs, which is why #23354 —
multi-argument calls handing every argument the trailing one's value — survived
with no diagnostic: f($x + 1, $x + 2) printed "12 12" and str_replace($p['from'],
$p['to'], 'xy!') returned "xy!", both running happily to completion.

24 of these 43 programs mismatched Zend on master when the corpus was written.
All are fixed (#23356, #23424); the corpus stays as the regression guard, and the
harness generalises to any directory of programs via --dir.

Cases are deliberately mundane — multi-argument calls by producer kind, mixed
producer kinds in one call, and the shapes the argument-resolution heuristics were
individually tuned against (var_export, usort, in_array, array_merge, sprintf,
by-ref, named args, spread, closures, static calls, constructor promotion).

Exit status is the mismatch count so it can gate a build.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.

2 participants