Skip to content

fix(generate): use correct state id when adding terminal states to non terminal extras#4792

Merged
amaanq merged 1 commit intotree-sitter:masterfrom
WillLillis:nonterminal_extra_ids
Sep 4, 2025
Merged

fix(generate): use correct state id when adding terminal states to non terminal extras#4792
amaanq merged 1 commit intotree-sitter:masterfrom
WillLillis:nonterminal_extra_ids

Conversation

@WillLillis
Copy link
Member

The Problem

When adding terminal states for non-terminal extras, we unconditionally use the length of the parse table's state vector to assign an id to the newly added terminal state. This assumes we're going to push to self.parse_table.states, which does not happen if add_parse_state is called with a state has already been added.

The Solution

Use the correct parse state id returned by add_parse_state.

@WillLillis WillLillis force-pushed the nonterminal_extra_ids branch from e144456 to fdf2447 Compare September 4, 2025 07:22
@WillLillis WillLillis added parser-generation Related to `tree-sitter generate` ci:backport release-0.25 Backport label labels Sep 4, 2025
@amaanq amaanq merged commit 5fd818b into tree-sitter:master Sep 4, 2025
22 checks passed
@tree-sitter-ci-bot
Copy link

Successfully created backport PR for release-0.25:

@maxbrunsfeld
Copy link
Contributor

Really nice debugging @WillLillis ⚡️⚡️⚡️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:backport release-0.25 Backport label parser-generation Related to `tree-sitter generate`

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Spurious ERROR node when using choice in extras definition

3 participants