Skip to content

Reject lone list spread assignment at compile time (#6936) - #6944

Merged
PurHur merged 1 commit into
masterfrom
agent/issue-6936-lone-list-spread-assign
Jun 6, 2026
Merged

PurHur merged 1 commit into
masterfrom
agent/issue-6936-lone-list-spread-assign

Conversation

@PurHur

@PurHur PurHur commented Jun 6, 2026

Copy link
Copy Markdown
Owner

Summary

php-src reference: Zend/zend_compile.c list assignment unpack validation.

PHP implementation: lib/Compiler.php — rejectLoneListSpreadAssign() called from compileListDestructGroup().

Closes #6936

Test plan

  • Issue repro fatals on VM
  • [$a, ...$rest] regression still prints 1:2,3,4
  • Compliance .phpt added

Verification

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php test/repro/maintainer_lone_list_spread_assign.php 2>&1 | head -1
# Fatal error: Spread operator is not supported in assignments in /compiler/test/repro/maintainer_lone_list_spread_assign.php on line 2

php bin/vm.php test/repro/maintainer_lone_list_spread_assign.php 2>&1 | head -1
# Fatal error: Spread operator is not supported in assignments in /compiler/test/repro/maintainer_lone_list_spread_assign.php on line 2

php bin/vm.php test/repro/list_destructuring_spread_4835.php
# 1:2,3,4

vendor/bin/phpunit --filter lone_list_spread
# OK (2 tests, 4 assertions)

vendor/bin/phpunit --filter list_destructuring_spread
# OK (2 tests, 2 assertions)

Made with Cursor

Zend rejects `[...$a] = $rhs` with a compile fatal; mirror that in
compileListDestructGroup via CompileFatal while keeping `[$a, ...$rest]`
destructuring from #4835 intact.

Co-authored-by: Cursor <cursoragent@cursor.com>
@PurHur
PurHur merged commit e7ad8d6 into master Jun 6, 2026
@PurHur
PurHur deleted the agent/issue-6936-lone-list-spread-assign branch June 6, 2026 15:43
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.

Language: lone spread in list assignment [...$a] = $rhs — VM accepts invalid syntax (zend_compile.c)

1 participant