Skip to content

Fix var_export($obj->method(), true) MethodCall inline arg slot (#17251) - #17262

Merged
PurHur merged 2 commits into
masterfrom
agent/issue-17251-var-export-method-call
Jul 7, 2026
Merged

PurHur merged 2 commits into
masterfrom
agent/issue-17251-var-export-method-call

Conversation

@PurHur

@PurHur PurHur commented Jul 7, 2026

Copy link
Copy Markdown
Owner

Summary

  • Fix var_export($it->current(), true) (and key() / generator current()) when php-cfg hoists a MethodCall producer plus trailing true ConstFetch: arg #0 was wired to the true slot instead of the MethodCall EXEC_RETURN slot.
  • Extend inline call-arg producer plumbing for MethodCall siblings separated by literal preludes (stmt-level next() before current()).
  • rewireVarExportNestedInlineCallArgSendSlots now detects hoisted true by literal name (not constant-pool index) and rewires arg #0 when both sends alias the true slot.

php-src reference

  • ext/standard/var.c — php_var_export_ex() arg #0 receives MethodCall result
  • Zend/zend_compile.c — ZEND_SEND_VAL / ZEND_SEND_VAR for call args

PHP implementation

  • lib/Compiler.php — sibling ordinal/target-arg index, rewireVarExportNestedInlineCallArgSendSlots, tryFoldHoistedBoolNullLiteralCallArg, resolveAdjacentNestedFuncCallArgSlot

Test plan

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && php bin/vm.php test/repro/maintainer_gap_var_export_method_call_current.php'
# ok

vendor/bin/phpunit --filter "testVarExportNestedArrayIteratorCurrentUsesMethodCallProducerSlot|testVarExportNestedArrayIteratorKeyUsesMethodCallProducerSlot|testVarExportNestedGeneratorCurrentUsesMethodCallProducerSlot"
# OK (3 tests)

vendor/bin/phpunit test/compliance/VMTest.php --filter var_export_method_call
# OK (1 test)

./script/ci-fast.sh
# green (inventory regen included)

Closes #17251

Made with Cursor

PurHur and others added 2 commits July 7, 2026 17:08
When var_export($obj->method(), true) is hoisted with a trailing ConstFetch,
both ARG_SEND slots drifted to the true literal; rewireVarExport now detects
the literal by name and binds arg #0 to the MethodCall EXEC_RETURN slot.

Co-authored-by: Cursor <cursoragent@cursor.com>
Combine methodCallIsStmtLevelDiscardPrelude (master) with rewireVarExport
true-literal detection and expanded MethodCall producer-slot coverage.

Co-authored-by: Cursor <cursoragent@cursor.com>
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.

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

1 participant