Skip to content

Language: keep arrow captures beside null in new args (#31720) - #31725

Merged
PurHur merged 1 commit into
masterfrom
agent/issue-31720-arrow-new-null-capture
Aug 17, 2026
Merged

Language: keep arrow captures beside null in new args (#31720)#31725
PurHur merged 1 commit into
masterfrom
agent/issue-31720-arrow-new-null-capture

Conversation

@PurHur

@PurHur PurHur commented Aug 17, 2026

Copy link
Copy Markdown
Owner

Summary

  • fn() => new Pair($x, null) / new Pair(null, $x) dropped auto-captured $x on VM (both args became null) while Zend kept the capture.
  • Root cause: positional hoisted null/true/false ConstFetch folding treated named CV / Phi temps as dead inline args.
  • Fix: exclude named locals from that positional map; force compileOperand for named CVs when a trailing bool/null ConstFetch prelude is present; do not treat named CVs as enum prelude slots.

Closes #31720

php-src: Zend/zend_compile.c (arrow auto-capture + ZEND_AST_NEW)

Test plan

  • ./script/docker-exec.sh -- bash -lc 'php test/repro/maintainer_gap_arrow_new_null_arg.php' (Zend) matches VM
  • ./script/docker-exec.sh -- bash -lc 'php bin/vm.php test/repro/maintainer_gap_arrow_new_null_arg.php'
    mixed_null a='captured' b=NULL
    null_then_cap a=NULL b='captured'
    int_control a='captured' b=0
    dup_control a='captured' b='captured'
    long_use a='captured' b=NULL
    
  • ./script/phpunit.sh --filter ArrowNewNullCapture31720Test → OK (2 tests, 11 assertions)

Made with Cursor

Positional ConstFetch null/true/false folding was binding onto named CV /
Phi auto-capture temps, so `fn() => new C($x, null)` lost `$x` on VM.

Co-authored-by: Cursor <cursoragent@cursor.com>
@PurHur
PurHur force-pushed the agent/issue-31720-arrow-new-null-capture branch from 4845358 to c1e8577 Compare August 17, 2026 00:58
@PurHur
PurHur merged commit 81c0eec into master Aug 17, 2026
1 check failed
@PurHur
PurHur deleted the agent/issue-31720-arrow-new-null-capture branch August 17, 2026 00:58
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.

Language: arrow fn new Class($captured, null) drops captures — both args null (Zend/zend_compile.c)

1 participant