Repository navigation
Fix AOT nullable ?string param returns via compile-time ?? rewrite (#8563) - #8586
Merged
Merged
Conversation
Compile-time rewrite maps the if-entry ?string arm to null === $param ? null : $param (php-src equivalent) and tracks the JumpIf so branch targets stay aligned with IDENTICAL. Verification: php vendor/bin/phpunit test/unit/NullableNeNullTernaryRewriteTest.php test/unit/TernaryReturnMergeSlotTest.php php bin/vm.php test/repro/aot_ternary_ne_null.php PHP_COMPILER_BOOTSTRAP_AOT_LINK=1 php bin/compile.php -o /tmp/n test/repro/aot_ternary_ne_null.php && /tmp/n Co-authored-by: Cursor <cursoragent@cursor.com>
Return typed string operands directly from the if-entry arm instead of reading the shared phi VALUE box after merge-block dead-operand frees. Nullable/union if-arms keep per-arm RETURN from the phi slot; pure string params skip the box on the string arm only. Verification: - test/repro/ns_nullable_ternary_return.php AOT exit 0 (was segfault) - test/repro/aot_ternary_bool.php AOT exit 0 - test/repro/getenv_identical_false.php AOT prints yes - make bootstrap-aot-link still 16 failures (ns_func, ne_null, …) Co-authored-by: Cursor <cursoragent@cursor.com>
…8563). Rewrite direct and ternary returns of explicit ?T params to $param ?? null (php-src equivalent) so native AOT uses the proven coalesce VALUE-box path. Register nullable scalar returns as __value__* in JIT ABI; cherry-pick ?: merge lowering from #8555. Verification: php vendor/bin/phpunit test/unit/NullableNeNullTernaryRewriteTest.php test/unit/NullableStringReturnAbiTest.php PHP_COMPILER_BOOTSTRAP_AOT_LINK=1 php bin/compile.php -o /tmp/t test/repro/aot_ternary_ne_null.php && /tmp/t PHP_COMPILER_BOOTSTRAP_AOT_LINK=1 php bin/compile.php -o /tmp/t test/repro/aot_nullable_param_direct_return.php && /tmp/t Co-authored-by: Cursor <cursoragent@cursor.com>
This was referenced Jun 14, 2026
4 tasks done
PurHur
added a commit
that referenced
this pull request
Jul 26, 2026
…curse AOT (#23482) (#23513) Arm-tail ternary returns called a missing Context method since #8586; resolve return/phi operands via the arm CFG block's scope slots so naive untyped fib compiles and matches Zend. Co-authored-by: PurHur <PurHur@users.noreply.github.com> Co-authored-by: Cursor <cursoragent@cursor.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes AOT segfault/abort when functions return explicit nullable parameters (
?string $n→?string) — the bootstrap-aot-link blocker tracked on #8561 / #8555.PHP-in-PHP approach:
lib/Compiler.php:return $paramandreturn (null !== $param ? $param : null)lower to$param ?? null(proven AOT-safe coalesce path)cfgFunctionReturnCallbackType: nullable scalar returns use__value__*ABI (parity withcfgParamIsImplicitNullable)emitCfgReturnOperand)Reference: Zend
ext/standardcoalesce semantics; php-src equivalent shapes for?stringparam/return ABI.Verification
make bootstrap-aot-linkstill has unrelated failures (hash/crypto/stdlib); this PR greens the nullable-param return repros that blockedns_func.php-class patterns.Closes #8563
Made with Cursor