Skip to content

Self-host: nested ?? compileExpr + PHPTypes null> fragments (#2276) - #3727

Merged
PurHur merged 1 commit into
masterfrom
agent/issue-2276-coalesce-compile-expr
May 30, 2026
Merged

PurHur merged 1 commit into
masterfrom
agent/issue-2276-coalesce-compile-expr

Conversation

@PurHur

@PurHur PurHur commented May 30, 2026

Copy link
Copy Markdown
Owner

Summary

Lane C picked #2276 after the open implementation-ready language queue in issue % 3 == 2 was entirely blocked (open PRs or stdlib-owned). Bootstrap inventory had regressed to 7 files reporting Expr_BinaryOp_Coalesce plus lib/JIT.php null> PHPDoc fragments.

  • lib/Compiler.php: handle Op\Expr\BinaryOp\Coalesce in compileExpr() via compileCoalesce() so nested ?? (e.g. (int) ($stat['mode'] ?? 0) in spine ext/standard/VmFs.php) lowers instead of hitting Unknown BinaryOp Type.
  • patches/php-types-generic-null-tail.patch: strip stray null> tails from PHPTypes::fromDecl() when unions inside list<T|null> split incorrectly during docblock reconstruction (lib/JIT.php).

php-src reference

  • Zend/zend_compile.c — zend_compile_coalesce() / ZEND_COALESCE (expression lowering)
  • Zend/zend_operators.c — ?? runtime (VM already had block-level path; this wires nested expr path)

Verification

./script/docker-exec.sh -- bash -lc './phpc lint --bootstrap-inventory'
# bootstrap-inventory: 0 files with unsupported syntax (854 scanned)

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && vendor/bin/phpunit --filter "CoalesceVmTest::testNullCoalesceNestedInCast|PhpcLintBootstrapInventoryTest"'

Note: CoalesceVmTest::testNullCoalesceThrow still errors on master (pre-existing); not introduced here.

Closes #2276

Made with Cursor

…ents (#2276)

Bootstrap inventory lint reported Expr_BinaryOp_Coalesce across lib/ and ext/
spine files because embedded ?? (e.g. in casts) hit compileExpr without the
block-level Coalesce path. Route Coalesce through compileCoalesce in compileExpr.

Strip trailing generic fragments like "null>" from PHPTypes::fromDecl so
list<Operand|null> PHPDoc on lib/JIT.php no longer fails type reconstruction.

Co-authored-by: Cursor <cursoragent@cursor.com>
@PurHur
PurHur force-pushed the agent/issue-2276-coalesce-compile-expr branch from 583b982 to a2cf916 Compare May 30, 2026 11:06
@PurHur
PurHur merged commit 2fa2792 into master May 30, 2026
@PurHur
PurHur deleted the agent/issue-2276-coalesce-compile-expr branch May 30, 2026 11:07
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.

Self-host: Unknown Stmt Type lowering batch tracker (post-#2254 triage)

1 participant