Skip to content

Fix nested substr(sprintf()) losing inner return (#10673) - #10685

Merged
PurHur merged 1 commit into
masterfrom
agent/issue-10673-substr-sprintf-nested
Jun 23, 2026
Merged

PurHur merged 1 commit into
masterfrom
agent/issue-10673-substr-sprintf-nested

Conversation

@PurHur

@PurHur PurHur commented Jun 23, 2026

Copy link
Copy Markdown
Owner

Summary

php-src reference

  • ext/standard/string.c — php_substr / php_sprintf
  • Zend/zend_execute.c — nested call temporaries

PHP implementation

  • lib/Compiler.php — siblingMultiArgFuncCallProducerTargetArgIndex, unary-prelude sibling producer matching

Verification

./script/docker-exec.sh -- bash -lc 'php bin/vm.php test/repro/maintainer_gap_substr_sprintf_nested.php'
# 0644

./script/docker-exec.sh -- bash -lc 'php vendor/bin/phpunit --filter nested_substr_sprintf'
# OK (2 tests)

./script/docker-exec.sh -- bash -lc 'php vendor/bin/phpunit --filter testSubstrNestedSprintfUsesFuncCallProducerSlot'
# OK (1 test, 5 assertions)

Closes #10673

Made with Cursor

Teach sibling multi-arg inline producer matching to allow a UnaryMinus
prelude between nested FuncCalls so sprintf feeds substr arg 0 while -N
feeds arg 1; add repro, compliance guard, and compile-slot unit test.

Co-authored-by: Cursor <cursoragent@cursor.com>
@PurHur
PurHur merged commit 6080b54 into master Jun 23, 2026
@PurHur
PurHur deleted the agent/issue-10673-substr-sprintf-nested branch June 23, 2026 04:05
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.

Stdlib: nested substr(sprintf()) — inner string lost, wrong slice (ext/standard/string.c)

1 participant