Skip to content

Language: list destructuring from null — target variables must remain unset (zend_execute.c parity) #4325

Description

@PurHur

Category

language

Problem

When the RHS of list destructuring is null (or other non-array/non-iterable scalars), Zend does not assign the list slots — variables stay unset (null on read). This compiler may still run ArrayDimFetch with literal keys 0, 1, … against a null/scalar container, producing notices or wrong values.

Related but distinct:

php-src reference

Repro (today)

<?php
[$a, $b] = null;
echo "a=", var_export($a, true), " b=", var_export($b, true), "\n";
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && php bin/vm.php -r "
[\$a,\$b]=null;
echo \"a=\",var_export(\$a,true),\" b=\",var_export(\$b,true),\"\\n\";
"'
Runtime Output
Zend PHP 8.x a=NULL b=NULL (both unset → null)
bin/vm.php may differ (offset on null / wrong values)

Also verify list($x) = false; and [$x] = 0; match Zend (no assignment).

Scope

Module Path
Compiler lib/Compiler.php — list-assign lowering after parseListAssignment
VM assign / dim-fetch guard or early skip
JIT mirror guard in list destructuring lowering
Tests test/compliance/cases/language/list_destructure_null.phpt

Done when

  • All three repros (null, false, 0) match Zend unset/null output on VM
  • JIT/AOT same behavior without VM fallback
  • ./script/ci-fast.sh --filter list_destructure_null green

Links

Activity

  1. added
    enhancementNew feature or request
    area:vmVirtual machine
    implementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claim
    on Jun 2, 2026
  2. PurHur commented on Jun 2, 2026

    @PurHur
    OwnerAuthor

    claim: worker-lane-c — starting this run

  3. PurHur commented on Jun 2, 2026

    @PurHur
    OwnerAuthor

    Merged via #4330

    Verification: php vendor/bin/phpunit --filter 'ListDestructNull|ListDestructStringKeys|list_destructure_null' → OK (5 tests). Issue repro outputs a=NULL b=NULL, x=NULL, y=NULL on VM. JIT LLVM module verify via ListDestructNullJitCompileTest.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:compilerCompiler / CFG / JITarea:vmVirtual machineenhancementNew feature or requestimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimphase-2:languagePhase 2 – language features

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions