Skip to content

Language: reject goto into switch like Zend (#28796) - #28813

Merged
PurHur merged 1 commit into
masterfrom
agent/issue-28796-goto-into-switch
Aug 8, 2026
Merged

PurHur merged 1 commit into
masterfrom
agent/issue-28796-goto-into-switch

Conversation

@PurHur

@PurHur PurHur commented Aug 8, 2026

Copy link
Copy Markdown
Owner

Summary

php-src: Zend/zend_compile.c'goto' into loop or switch statement is disallowed.

Test plan

  • Issue repro (VM + JIT): exit 255, message contains 'goto' into loop or switch statement is disallowed, no HIT
  • eval goto-into-switch: exit 255, Zend-shaped Fatal
  • vendor/bin/phpunit --filter GotoStatementTest — OK (7)
  • vendor/bin/phpunit test/compliance/GotoVMTest.php — OK (11)
  • script/apply-patches.sh skips jumptable patch when already applied

Verification transcript

$ php bin/vm.php /tmp/goto_switch.php; echo exit:$?
parseAndCompile failure: target=/tmp/goto_switch.php: 'goto' into loop or switch statement is disallowed
exit:255

$ php bin/jit.php /tmp/goto_switch.php; echo exit:$?
parseAndCompile failure: target=/tmp/goto_switch.php: 'goto' into loop or switch statement is disallowed
exit:255

$ php bin/vm.php /tmp/goto_switch_eval.php; echo exit:$?
PHP Fatal error:  'goto' into loop or switch statement is disallowed in ... eval()'d code on line 1
exit:255

Made with Cursor

)

php-cfg already tracked loop/switch scope for the desugar switch path, but
scalar-case switches use compileJumptableSwitch which skipped the stack — so
goto into switch ran. Push the same scope id there, throw CompileError instead
of RuntimeException for clean exit 255, and guard with compliance + unit tests.

Co-authored-by: Cursor <cursoragent@cursor.com>
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: goto into switch executes — Zend E_COMPILE_ERROR disallowed (Zend/zend_compile.c)

1 participant