Summary
A match whose arms return heterogeneous mixed values (object / array / string) compiles but dies at runtime — the match-arm type unification appears to coerce the object arm to string.
Verified on
main (7396e65b), macOS ARM64.
Minimal reproduction
<?php
function pick(int $n): mixed {
return match($n % 3) { 0 => new stdClass(), 1 => [1, 2], default => "s" };
}
$c = 0;
for ($n = 0; $n < 6; $n++) {
$v = pick($n);
$c += is_object($v) ? 10 : (is_array($v) ? 7 : 3);
}
echo $c;
Actual
Runtime fatal (Object of class stdClass could not be converted to string), no output.
Expected (PHP)
Notes
Found while stress-testing mixed-value shapes for the #484 review. The arms individually work; it is the heterogeneous unification of the match result that mis-coerces.
Summary
A
matchwhose arms return heterogeneousmixedvalues (object / array / string) compiles but dies at runtime — the match-arm type unification appears to coerce the object arm to string.Verified on
main(7396e65b), macOS ARM64.Minimal reproduction
Actual
Runtime fatal (
Object of class stdClass could not be converted to string), no output.Expected (PHP)
Notes
Found while stress-testing mixed-value shapes for the #484 review. The arms individually work; it is the heterogeneous unification of the match result that mis-coerces.