Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(parser): gracefully handle stalled parser in object patterns #5198

Merged
merged 2 commits into from
Feb 25, 2025

Conversation

arendjr
Copy link
Contributor

@arendjr arendjr commented Feb 25, 2025

Summary

Fixes #4622.

In some cases, ) and ] could cause the parser to stall inside object patterns, triggering an internal assertion.

I was initially able to create a very specific fix by checking for these two characters, but it also created some fallout in other snapshots. Those snapshots were also for error cases, so it wasn't a dealbreaker, but the fix itself also felt brittle: what if another character or combination could trigger a stalled parser too?

So instead I changed how ParserProgress works, allowing us to gracefully handle stalled parsers. This way we don't fail with an assertion, but we can provide a nice diagnostic.

Test Plan

Test case added.

@arendjr arendjr requested review from a team February 25, 2025 08:58
@github-actions github-actions bot added A-Parser Area: parser L-JavaScript Language: JavaScript and super languages labels Feb 25, 2025
Copy link

codspeed-hq bot commented Feb 25, 2025

CodSpeed Performance Report

Merging #5198 will not alter performance

Comparing arendjr:fix-error-recovery-on-invalid-objects (c4b6113) with main (0750b40)

Summary

✅ 97 untouched benchmarks

@arendjr arendjr merged commit b0046bf into biomejs:main Feb 25, 2025
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Parser Area: parser L-JavaScript Language: JavaScript and super languages
Projects
None yet
Development

Successfully merging this pull request may close these issues.

🐛 Unexpected error The parser is no longer progressing
2 participants