Skip to content

Language: nullsafe ?-> method call inline arg compile + short-circuit (#17186) - #17188

Merged
PurHur merged 1 commit into
masterfrom
agent/issue-17186-nullsafe-method-args-compile
Jul 7, 2026
Merged

Language: nullsafe ?-> method call inline arg compile + short-circuit (#17186)#17188
PurHur merged 1 commit into
masterfrom
agent/issue-17186-nullsafe-method-args-compile

Conversation

@PurHur

@PurHur PurHur commented Jul 7, 2026

Copy link
Copy Markdown
Owner

Summary

  • Pass NullsafeMethodCall as $cfgCallOp into compileCallArgSends() so inline argument lowering no longer fatals in outerSiblingInlineCallArgProducerSlot().
  • Defer immediately preceding inline arg producers (IIFE FuncCall + Closure) into the nullsafe fetch block so arguments are not evaluated when the receiver is null (Language: nullsafe operator (?->) — short-circuit + error semantics parity #4394 / php-src ?-> short-circuit).

Root cause

compileNullsafeMethodCall() called compileCallArgSends($expr->args, $fetchBlock) without the CFG call op. php-cfg also uses a distinct arg temporary (#6) vs the inline producer result (#5), so the existing prelude deferral slice never matched IIFE arguments.

php-src reference

  • Zend/zend_compile.c — nullsafe method call compile; argument evaluation only on non-null receiver branch

PHP implementation

  • lib/Compiler.phpcompileNullsafeMethodCall, deferred nullsafe prelude scan, isNullsafeMethodCallArgPreludeProducer()

Verification

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
vendor/bin/phpunit --filter "nullsafe_method_args_short_circuit|nullsafe_chain_method"
php bin/vm.php test/repro-maintainer/nullsafe_method_args.php
php test/repro-maintainer/nullsafe_method_args.php'
PHPUnit OK (2 tests, 2 assertions)
VM: NULL / call / 2  (matches Zend)

Closes #17186

Made with Cursor

…cuit (#17186)

Pass the NullsafeMethodCall CFG op into compileCallArgSends and defer
immediately preceding inline arg producers (IIFE FuncCall) into the
non-null fetch block so arguments are not evaluated on a null receiver.

Co-authored-by: Cursor <cursoragent@cursor.com>
@PurHur
PurHur merged commit 33c4d58 into master Jul 7, 2026
@PurHur
PurHur deleted the agent/issue-17186-nullsafe-method-args-compile branch July 7, 2026 12:40
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: nullsafe ?-> method call with inline arg — compile TypeError in Compiler.php (Zend/zend_compile.c)

1 participant