Skip to content

Language: list destructuring from null — targets stay unset (#4325) - #4330

Merged
PurHur merged 1 commit into
masterfrom
agent/issue-4325-list-destruct-null
Jun 2, 2026
Merged

PurHur merged 1 commit into
masterfrom
agent/issue-4325-list-destruct-null

Conversation

@PurHur

@PurHur PurHur commented Jun 2, 2026

Copy link
Copy Markdown
Owner

Summary

  • Wrap list() / [] destructuring groups in TYPE_LIST_UNPACK_CHECK CFG lowering so non-array RHS (null, false, 0) skips dim-fetch assignments instead of throwing "Illegal offset" (Zend zend_execute.c parity).
  • VM merge blocks inherit assign slots after successful unpack; JIT adds guarded branches with LLVM module verify (MCJIT execute skipped in umbrella JITTest like other list-unpack paths until stable).

php-src reference

  • Zend/zend_execute.c — list assignment on non-array types

Verification

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && php -r "
require \"vendor/autoload.php\";
\$r = new PHPCompiler\\Runtime();
ob_start();
\$r->run(\$r->parseAndCompile(\"<?php [\\\$a,\\\$b]=null; echo \\\"a=\\\",var_export(\\\$a,true),\\\" b=\\\",var_export(\\\$b,true),\\\"\\\\n\\\"; list(\\\$x)=false; echo \\\"x=\\\",var_export(\\\$x,true),\\\"\\\\n\\\"; [\\\$y]=0; echo \\\"y=\\\",var_export(\\\$y,true),\\\"\\\\n\\\";\", \"t.php\"));
echo ob_get_clean();
"'
# a=NULL b=NULL
# x=NULL
# y=NULL

php vendor/bin/phpunit --filter "ListDestructNull|ListDestructStringKeys|list_destructure_null"
# OK (5 tests, 5 assertions)

Closes #4325

Made with Cursor

…).

Guard list() / [] groups with TYPE_LIST_UNPACK_CHECK CFG so non-array RHS
skips dim-fetch assignments (Zend zend_execute.c parity). JIT LLVM verify
covers the new branch; MCJIT execute remains gated like other list unpack paths.

Co-authored-by: Cursor <cursoragent@cursor.com>
@PurHur
PurHur merged commit c46ddba into master Jun 2, 2026
@PurHur
PurHur deleted the agent/issue-4325-list-destruct-null branch June 2, 2026 04:44
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: list destructuring from null — target variables must remain unset (zend_execute.c parity)

1 participant