Category
language
Problem
Numeric list spread [$a, ...$rest] = $arr is VM-complete (#4835). Keyed list destructuring with a spread arm — e.g. ['label' => $label, ...$others] = $assoc — is not covered by compliance tests and may use the wrong tail offset: php-cfg spread lowering uses listSpreadFromIndex counting only positional slots, while Zend merges remaining elements after consuming keyed assignments.
Workers should not assume keyed+spread works because numeric spread PHPT passes.
php-src reference
Repro
<?php
$src = ['label' => 'L', 'a' => 1, 'b' => 2];
['label' => $label, ...$rest] = $src;
ksort($rest);
var_export($label);
echo "\n";
var_export($rest);
php repro_keyed_list_spread.php
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && php bin/vm.php repro_keyed_list_spread.php'
Record Zend output as authoritative; today VM may assign wrong keys into $rest or fail compile.
Stretch: string-key spread tail must still error when remainder is not a list (same as #4835).
Scope
| Area |
Files |
| php-cfg patch |
script/apply-patches.sh — parseListAssignment spread index for keyed arms |
| Compiler |
lib/Compiler.php — TYPE_LIST_SPREAD_ASSIGN offset semantics |
| VM |
lib/VM.php — merge keyed slots then append list tail |
| Tests |
test/compliance/cases/language/list_destructuring_keyed_spread.phpt |
| JIT |
Follow #4885 after VM green |
Done when
Links
Category
languageProblem
Numeric list spread
[$a, ...$rest] = $arris VM-complete (#4835). Keyed list destructuring with a spread arm — e.g.['label' => $label, ...$others] = $assoc— is not covered by compliance tests and may use the wrong tail offset: php-cfg spread lowering useslistSpreadFromIndexcounting only positional slots, while Zend merges remaining elements after consuming keyed assignments.Workers should not assume keyed+spread works because numeric spread PHPT passes.
php-src reference
Zend/zend_compile.c—zend_compile_list_assignkeyed + unpackZend/zend_execute.c— list assign runtimeRepro
php repro_keyed_list_spread.php ./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && php bin/vm.php repro_keyed_list_spread.php'Record Zend output as authoritative; today VM may assign wrong keys into
$restor fail compile.Stretch: string-key spread tail must still error when remainder is not a list (same as #4835).
Scope
script/apply-patches.sh—parseListAssignmentspread index for keyed armslib/Compiler.php—TYPE_LIST_SPREAD_ASSIGNoffset semanticslib/VM.php— merge keyed slots then append list tailtest/compliance/cases/language/list_destructuring_keyed_spread.phptDone when
var_exportoutput matches Zend on VMci-fast --filter list_destructuring_keyedgreenLinks