Skip to content

Regression: extract() EXTR_OVERWRITE duplicate keys — first value wins not last (ext/standard/basic_functions.c) #13722

Closed

Description

@PurHur

Category

stdlib · php-src-strict

Problem

When extract() receives an array literal with duplicate string keys, EXTR_OVERWRITE must apply entries in order so the last value wins (php-src walks the array sequentially).

VM keeps the first value instead.

php-src reference

Repro (verified 2026-06-29)

<?php
declare(strict_types=1);
extract(['a' => 1, 'a' => 2], EXTR_OVERWRITE);
var_export($a);
echo "\nok\n";
./script/docker-exec.sh -- bash -lc 'php test/repro/maintainer_gap_extract_extr_overwrite_duplicate.php'
./script/docker-exec.sh -- bash -lc 'php bin/vm.php test/repro/maintainer_gap_extract_extr_overwrite_duplicate.php'
Check Zend VM
$a after duplicate-key EXTR_OVERWRITE 2 1

Note: EXTR_SKIP duplicate-key behavior already matches (2).

Scope (PHP-in-PHP first)

Layer Path
VM builtin ext/standard/extract.php, ext/standard/VmExtract.php (or equivalent helper)
Hash iteration ensure duplicate keys in inline/literal arrays preserve last-wins order
JIT/AOT mirror after VM guard green

Done when (php-src-strict)

  • Duplicate-key EXTR_OVERWRITE last value wins
  • Other EXTR_* modes unchanged
  • test/repro/maintainer_gap_extract_extr_overwrite_duplicate.php exits 0 on VM

Verification

php bin/vm.php test/repro/maintainer_gap_extract_extr_overwrite_duplicate.php

Links

Activity

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

    @PurHur
    OwnerAuthor

    claim: PHP Runtime → PHP — batch (issues #13722, #10547)

  3. PurHur commented on Jun 29, 2026

    @PurHur
    OwnerAuthor

    claim: PHP Runtime → PHP — batch (issues #13748, #13750, #13722)

  4. PurHur commented on Jun 29, 2026

    @PurHur
    OwnerAuthor

    Verified on master (2026-06-29): VM returns 2 for duplicate-key EXTR_OVERWRITE — matches Zend. Closing candidate.

  5. PurHur commented on Jun 29, 2026

    @PurHur
    OwnerAuthor

    claim: PHP Compiler STD Lib — batch (issue #13722, continuing after #13800 merge)

  6. PurHur commented on Jun 29, 2026

    @PurHur
    OwnerAuthor

    Verified on master after #13807 merge: duplicate-key EXTR_OVERWRITE repro returns 2 on VM (matches Zend). No code change needed — please close if still open.

  7. PurHur commented on Jun 30, 2026

    @PurHur
    OwnerAuthor

    claim: PHP Runtime → PHP — batch (issues #14103, #13722)

  8. PurHur commented on Jun 30, 2026

    @PurHur
    OwnerAuthor

    Closing as stale: repro green on master 2026-06-30 (verified by PHP Runtime migration run after #14222).

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:vmVirtual machineenhancementNew feature or requestimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimphase-4:stdlibPhase 4 – stdlib for web appsstdlib

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions