Skip to content

Stdlib: array_map(null, $a, $b) — zip uses duplicate column not parallel (ext/standard/array.c) #13812

Closed

Description

@PurHur

Category

stdlib · php-src-strict

Problem

Zend array_map(null, $a, $b) zips arrays in parallel: [[a0,b0], [a1,b1], ...]. This compiler duplicates the second column into both slots:

array_map(null, [1, 2], [3, 4]);
// Zend: [[1, 3], [2, 4]]
// VM:   [[3, 3], [4, 4]]  ← wrong

Distinct from #9143 (single-array array_map(null, $array) identity form).

php-src reference

Repro (verified 2026-06-29)

test/repro/maintainer_gap_array_map_null_zip.php

php bin/vm.php test/repro/maintainer_gap_array_map_null_zip.php
Check Zend VM
array_map(null, [1,2], [3,4]) [[1,3],[2,4]] [[3,3],[4,4]]

Scope (PHP-in-PHP first)

Layer Path
VM ext/standard/array_map.php, ext/standard/VmArray.php
JIT array_map null-callback zip lowering

Done when (php-src-strict)

  • Repro exits 0 on VM
  • 3+ array zip form matches Zend
  • JIT/AOT agree when in scope

Verification

php bin/vm.php test/repro/maintainer_gap_array_map_null_zip.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 Compiler STD Lib — batch (issues #13812, #13811, #13810)

  3. PurHur commented on Jun 29, 2026

    @PurHur
    OwnerAuthor

    claim: PHP Runtime → PHP — batch (issues #13812)

  4. PurHur commented on Jun 29, 2026

    @PurHur
    OwnerAuthor

    Merged in #13813.

    Fix: compileCallArgSends + matchInlineCallArgProducerWithEmbeddedLiterals now remap array_map arg slots when the null callback and inline array literals share php-cfg temps.

    Verified: VM/JIT array_map(null, [1,2], [3,4]) → [[1,3],[2,4]]; compliance array_map_null_zip.phpt; repro script; vendor/bin/phpunit --filter testArrayMapNullZip; bootstrap VM driver probe OK.

  5. PurHur commented on Jun 29, 2026

    @PurHur
    OwnerAuthor

    Merged via #13814.

    Fix: compiler maps sibling inline Array_ hoists to array_map array operands by positional index (lib/Compiler.php).

    Verification:

    php -d display_errors=0 bin/vm.php test/repro/maintainer_gap_array_map_null_zip.php  # ok
    php -d display_errors=0 bin/compile.php -l test/repro/maintainer_gap_array_map_null_zip.php  # AOT lint ok
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