Skip to content

playground#5

Merged
math3usmartins merged 2 commits into
mainfrom
feat/playground
May 21, 2026
Merged

playground#5
math3usmartins merged 2 commits into
mainfrom
feat/playground

Conversation

@math3usmartins

Copy link
Copy Markdown
Member

No description provided.

playground/ is a self-contained sandbox app with its own composer.json
that depends on xphp-lang/xphp-parser via a Composer path repository
pointing at the repo root — the same shape any downstream consumer
would use. `make playground` (or playground/bin/run) compiles every
.xphp under src/, then runs four demos covering the supported feature
buckets: single-type generics, multi-type generics, T[] / ?T sugar,
and transitive specialization via Wrapper<T> referencing Box<T>.

Wiring the playground up surfaced a real bug: the T[] sugar treated
any Name followed by `[]` as a type-hint, including `$this->keys[]`
array-append (where `keys` is a T_STRING after `->`). The destructive
rewrite turned property writes into writes to a dynamic `$array` slot.

Add an isMemberAccessContext guard that walks back past whitespace and
comments from the Name token; if the previous meaningful token is `->`,
`?->`, or `::`, skip the sugar. Cover the three operators plus the
walk-back-past-comment path in unit tests.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@math3usmartins math3usmartins force-pushed the feat/playground branch 2 times, most recently from 70fddbe to ccf08d6 Compare May 21, 2026 01:47
@math3usmartins math3usmartins merged commit 421fe84 into main May 21, 2026
2 checks passed
@math3usmartins math3usmartins deleted the feat/playground branch May 31, 2026 19:34
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.

1 participant