Skip to content

fix(generate): warn users when extra rule can lead to parser hang#4750

Merged
WillLillis merged 1 commit intotree-sitter:masterfrom
WillLillis:infinite_warnings
Aug 30, 2025
Merged

fix(generate): warn users when extra rule can lead to parser hang#4750
WillLillis merged 1 commit intotree-sitter:masterfrom
WillLillis:infinite_warnings

Conversation

@WillLillis
Copy link
Member

The problem

When a named rule in extras is able to match the empty string, parsing can hang in certain situations (i.e. near EOF). This is demonstrated by #4405.

The Solution

There isn't a great way to fix the actual hang in the core lib. An easy workaround for grammar authors is to simply inline the rule in question into extras. The CLI will now warn during generation if such a case is detected.

@clason clason added parser-generation Related to `tree-sitter generate` ci:backport release-0.25 Backport label labels Aug 29, 2025
When a *named* rule in the extras is able to match the empty string,
parsing can hang in certain situations (i.e. near EOF).
@WillLillis WillLillis merged commit ac171eb into tree-sitter:master Aug 30, 2025
18 checks passed
@WillLillis WillLillis deleted the infinite_warnings branch August 30, 2025 01:38
@tree-sitter-ci-bot
Copy link

Successfully created backport PR for release-0.25:

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.

tree-sitter parse hangs parsing string literal

3 participants