Skip to content

Keep pocket table indexes in step with AST edits made after validation - #1998

Merged
TwitchBronBron merged 1 commit into
v1from
fix/live-pocket-table-index
Nov 20, 2026
Merged

TwitchBronBron merged 1 commit into
v1from
fix/live-pocket-table-index

Conversation

@TwitchBronBron

Copy link
Copy Markdown
Member

Pocket table indexes were captured once at link time, but the defining node's statementIndex is computed live. When a plugin inserts statements into a block after validation (e.g. rooibos code coverage), the two drift apart: a local can look not-yet-defined and gets transpiled as a same-named namespace member (user.settings.x → user_settings_x, isWanted[...] → guide_isWanted[...]).

  • PocketTable.index is now a getter that tracks the current AST. It caches the index and only redoes the indexOf once the block has actually shifted.
  • getPossiblePocketTables reads index once per table.
  • Added a regression test that inserts statements in beforePrepareFile and checks the transpiled output.

Perf: allows many gotos to the same label (a function with 2000 if blocks) validates in ~255ms vs ~150–180ms before. An uncached live index took ~2.4s. Normal code shouldn't see a difference.

Verified: full suite passes (5690), lint and tsc clean, and the new test fails without the fix.

🤖 Generated with Claude Code

Pocket table indexes were captured once at link time, while the defining node's
statementIndex is computed live. A plugin that inserts statements into a block
after validation (e.g. rooibos code coverage) shifted one but not the other, so
a local could be treated as not-yet-defined and transpiled as a namespace member.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@TwitchBronBron
TwitchBronBron merged commit e04b454 into v1 Nov 20, 2026
9 checks passed
@TwitchBronBron
TwitchBronBron deleted the fix/live-pocket-table-index branch November 20, 2026 20:45
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