Skip to content

Regression: var_export($obj->method(), true) returns NULL — MethodCall inline arg slot (ext/standard/var.c, lib/Compiler.php) #17251

Description

@PurHur

Category

Regression · php-src-strict · compile inline-arg wiring

Problem

var_export($iterator->current(), true) and similar MethodCall first arguments return NULL in return mode on master (2026-07-07) while Zend exports the scalar/object result. echo $it->current() works; only var_export(..., true) is broken — inline call-arg producer slot does not bind the MethodCall result (#10778 family).

Repro Zend 8.2+ VM (2026-07-07)
$it=new ArrayIterator([1,2]); $it->next(); var_export($it->current(),true) '2' NULL
var_export((new ArrayIterator([1]))->current(), true) 1 NULL

php-src reference

PHP implementation target

Repro

./script/docker-exec.sh -- bash -lc 'php bin/vm.php test/repro/maintainer_gap_var_export_method_call_current.php'

Done when

  • test/repro/maintainer_gap_var_export_method_call_current.php prints ok on VM/JIT/AOT
  • InlineCallArgProducerSlotTest::{testVarExportNestedArrayIteratorCurrentUsesMethodCallProducerSlot,testVarExportNestedArrayIteratorKeyUsesMethodCallProducerSlot} green
  • Compliance .phpt under test/compliance/cases/stdlib/var_export_method_call.phpt
  • php-src-strict; no php-compiler-strict shortcut

Activity

  1. added
    bugSomething isn't working
    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 Jul 7, 2026
  2. PurHur commented on Jul 7, 2026

    @PurHur
    OwnerAuthor

    claim: cursor-agent-lane-b — starting this run

  3. PurHur commented on Jul 7, 2026

    @PurHur
    OwnerAuthor

    claim: cursor-agent-lane-b — starting this run

  4. PurHur commented on Jul 7, 2026

    @PurHur
    OwnerAuthor

    Merged via #17255

    Fix: Skip stmt-level iterator pointer MethodCall discard preludes (next(), etc.) when resolving sibling inline call-arg producer slots for var_export($obj->method(), true).

    Verification (green on merge):

    • php bin/vm.php test/repro/maintainer_gap_var_export_method_call_current.php → ok
    • InlineCallArgProducerSlotTest::{testVarExportNestedArrayIteratorCurrentUsesMethodCallProducerSlot,testVarExportNestedArrayIteratorKeyUsesMethodCallProducerSlot}
    • test/compliance/cases/stdlib/var_export_method_call.phpt (VM + JIT)
  5. PurHur commented on Jul 7, 2026

    @PurHur
    OwnerAuthor

    Merged via #17262

    Root cause: rewireVarExportNestedInlineCallArgSendSlots only rewired arg #0 when it pointed at an INIT_ARRAY slot; when both TYPE_ARG_SEND ops drifted to the hoisted true ConstFetch slot (arg2 is the literal name operand, not a constant-pool index), arg #0 was never corrected.

    Fix: Detect hoisted true by literal name, rewire arg #0 to the MethodCall EXEC_RETURN slot; extend sibling producer ordinal/target-arg logic for stmt-level next() before current().

    Verification:

    php bin/vm.php test/repro/maintainer_gap_var_export_method_call_current.php  # ok
    vendor/bin/phpunit --filter 'testVarExportNestedArrayIteratorCurrentUsesMethodCallProducerSlot|testVarExportNestedArrayIteratorKeyUsesMethodCallProducerSlot|testVarExportNestedGeneratorCurrentUsesMethodCallProducerSlot'
    vendor/bin/phpunit test/compliance/VMTest.php --filter var_export_method_call
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 machinebugSomething isn't workingimplementation-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