Skip to content

Fix ?? on $_GET keys without undefined-key warning (VM) - #431

Merged
PurHur merged 2 commits into
masterfrom
fix/coalesce-superglobal-isset
May 21, 2026
Merged

Fix ?? on $_GET keys without undefined-key warning (VM)#431
PurHur merged 2 commits into
masterfrom
fix/coalesce-superglobal-isset

Conversation

@PurHur

@PurHur PurHur commented May 21, 2026

Copy link
Copy Markdown
Owner

Summary

  • Fixes compiler lowering when php-cfg emits ArrayDimFetch as a separate statement before ?? (common for $_GET['name'] ?? 'Guest').
  • Skips the eager dim-fetch that triggered Warning: Undefined array key before the coalesce branch; uses isset(container, dim) instead.
  • Adds VM compliance + real PHPT coverage; documents the recommended pattern in docs/runtime-semantics.md.

Issue

Closes #273 (undefined superglobal key + ?? pattern). Builds on closed #99 (null coalescing).

Test plan

  • docker run … php-compiler:22.04-dev ./script/ci-local.sh --filter coalesce
  • $_GET['name'] ?? 'Guest' with empty QUERY_STRINGGuest, no warning
  • QUERY_STRING=name=WorldWorld

Follow-up

AOT/JIT ?? on runtime superglobals still needs LLVM merge/phi work (module verify fails today); left examples/001-SimpleWeb on direct $_REQUEST['name'] until that lands.

Made with Cursor

PurHur and others added 2 commits May 21, 2026 07:59
php-cfg emits ArrayDimFetch before Coalesce as separate statements; the eager
fetch ran before isset and triggered Zend-style warnings. Skip the orphan fetch,
resolve the dim fetch for isset(container, dim), and add VM/real regression tests.

Closes #273 follow-up for the recommended $_GET['key'] ?? default pattern (VM).
AOT/JIT coalesce on runtime superglobals remains a separate LLVM merge fix.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
@PurHur
PurHur merged commit f61395a into master May 21, 2026
@PurHur
PurHur deleted the fix/coalesce-superglobal-isset branch May 21, 2026 07:59
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.

Runtime: Undefined array/superglobal key — Zend notice parity Language: Null coalescing operator (??) in compiler pipeline

1 participant