Skip to content

Fix $this in switch/if branches for MiniWebApp VM dispatch#516

Merged
PurHur merged 1 commit into
masterfrom
fix/switch-branch-this-scope
May 22, 2026
Merged

Fix $this in switch/if branches for MiniWebApp VM dispatch#516
PurHur merged 1 commit into
masterfrom
fix/switch-branch-this-scope

Conversation

@PurHur
Copy link
Copy Markdown
Owner

@PurHur PurHur commented May 22, 2026

Summary

  • Inherit parent function scope when compiling CFG branch targets (switch cases, if/else, jumps) so branch blocks share slot indices with the enclosing method.
  • Resolve $this in Block::getFrame() via calledArgs on ancestor frames, not only immediate callArgs (fixes nested switch in Router::dispatch()).
  • Update PhpcLintProjectTest for green 003-MiniWebApp lint; add switch_method_call compliance + unit coverage.

Why

examples/003-MiniWebApp VM serve failed with Could not resolve argument when Router::dispatch() called private render methods from switch cases — blocking the reference web app path toward AOT (#210, #67).

Test plan

  • ./script/docker-ci-local.sh fast --filter 'SwitchMethodCallTest|PhpcLintProjectTest|MiniWebAppSkeleton'
  • Manual: php bin/vm.php on 003-MiniWebApp dispatch('GET','home') returns HTML
  • Full ./script/ci-local.sh on merge host (LLVM)

Closes #210

Made with Cursor

Inherit parent scope when compiling branch blocks and walk caller
calledArgs so MiniWebApp Router dispatch runs under VM serve.

Closes #210 (VM path). Adds switch_method_call compliance + unit test.

Co-authored-by: Cursor <cursoragent@cursor.com>
@PurHur PurHur merged commit e5676a4 into master May 22, 2026
@PurHur PurHur deleted the fix/switch-branch-this-scope branch May 22, 2026 11:56
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.

Web: MiniWebApp routing pattern (front controller + path dispatch)

1 participant