Skip to content

JIT: fix global/foreach/try assign lowering for AOT spine (#16828) - #16854

Merged
PurHur merged 1 commit into
masterfrom
agent/issue-16828-global-assign-foreach-try
Jul 6, 2026
Merged

PurHur merged 1 commit into
masterfrom
agent/issue-16828-global-assign-foreach-try

Conversation

@PurHur

@PurHur PurHur commented Jul 6, 2026

Copy link
Copy Markdown
Owner

Summary

  • Prescan global $name imports across the whole function CFG before lowering try-merge blocks (foreach valid phi could compile before DECLARE_GLOBAL).
  • Teach assignOperandValue / assignOperand to handle native-scalar and string KIND_VALUE phi operands instead of throwing.
  • Harden TYPE_ASSIGN / TYPE_CONCAT when alias/dest operands are null (literal-RHS peephole).

Closes #16828 (assign-guard blocker). Full spine bundle now progresses past Cannot assign to a value / Cannot assignOperandValue to a value and fails later on Forward reference to class constant DateException::class (separate compile issue).

Verification

php bin/compile.php -o /tmp/aot_test test/fixtures/aot/compile-only/global_foreach_try_after_early_return.php
# (no output, exit 0)

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

php bin/compile.php -o /tmp/spine test/selfhost/compiler_lib_spine_smoke/main.php 2>&1 | tail -1
# Forward reference to class constant DateException::class
# (was: Cannot assign to a value)

Test plan

  • Issue repro fixture AOT-compiles
  • BootstrapAotJitCompileTest::testGlobalForeachTryAfterEarlyReturnCompiles (Docker/LLVM)
  • Spine smoke compile no longer hits assignOperand guard (next blocker documented)

Made with Cursor

Prescan `global $name` imports before try-merge blocks compile, allow native
scalar and string phi rvalues in assignOperandValue, and harden TYPE_ASSIGN
when alias operands are absent. Spine AOT now passes the original assign guard
and fails later on DateException::class forward ref.

Co-authored-by: Cursor <cursoragent@cursor.com>
@PurHur
PurHur force-pushed the agent/issue-16828-global-assign-foreach-try branch from 8493997 to 05d5008 Compare July 6, 2026 09:40
@PurHur
PurHur merged commit 87ee6a2 into master Jul 6, 2026
@PurHur
PurHur deleted the agent/issue-16828-global-assign-foreach-try branch July 6, 2026 09: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.

Self-host: spine bundle native emit fails — JIT 'Cannot assign to a value' (lib/JIT.php:12225); gen-0 sidecar refresh blocked

1 participant