You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
feat(reflection): optimizer-aware frame-variable presence/enumeration API on ExecutionData #240
With opcache active, the optimizer (SCCP + dead-code elimination + CV compaction) legitimately removes and renumbers compiled-variable slots. Frame introspection then sees the optimized truth: a variable that exists in the source may have no CV slot at runtime, and ExecutionData::getLocalVariable() throws OutOfBoundsException for it.
Found by running the full suite with opcache.enable_cli=1 in the runner: tests/System/ExecutionDataTest::testGetLocalVariableObservesUndefSlot (never-assigned CV dropped after range inference proves its branch dead) and ::testGetLocalVariablesOfParentFrame (a marker CV removed by SCCP + DCE) fail; both pass with opcache.optimization_level=0. Identical on the 8.4 and master lines; deterministic.
Agreed design (discussed with the maintainer)
Hybrid stance:
Document the optimizer reality — introspection reports the optimized op_array truthfully; instrumentation scenarios that must see every source variable should run with opcache.optimization_level=0 (docs/self-debugging.md).
Keep the throw on access to a missing variable (getLocalVariable() keeps its OutOfBoundsException).
Add presence/enumeration API so clients can probe before access, following the existing naming family:
promote the existing private ExecutionData::getLocalVariableNames() (slot-keyed array<int, string>) to public.
Tests adapt to be branch-aware: probe presence first; when the slot is present (default opcache-off CI) the original strict assertions run unchanged, when absent (opcache-active runner) the throw / empty-shape contract is asserted instead.
Activity