Repository navigation
Conversation
The recovering parse reads a missing statement as an empty one without advancing, so parse_block looped until it found a closing brace. A half-typed handler like `onClick={() => { c` made analyze take 8 to 27 seconds.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The recovering parse an editor uses (
parse_program_recovering, behindanalyze) did not stop on a block that is still open when the input ends. Typing a handler such asmade
analyzerun for 8 to 27 seconds in the playground from #70, and the same input reaches the language server through the same code.Root cause
In a recovering parse, a missing expression is read as an empty one and recorded as an error, so
parse_stmtreturnsOkwithout advancing.parse_blockloopswhile !c.starts_with("}")with nothing between statements that has to be there, so at the end of input, or at any character a statement cannot start with, each pass reads nothing and the loop goes round again. The list loops (arguments, arrays, records, imports) do not have this problem: they break when the,is missing.Change
parse_blockrecords the cursor before each statement and breaks when a pass has not moved it. Theexpect("}")that follows then fails as it would for any unclosed block, and the recovering loader records that as the parse error. The strict parse (parse_program) is unaffected: thereparse_stmteither advances or returnsErr, so the new branch is never taken.Verification
cargo test --release --manifest-path compiler/Cargo.toml: 11 lib tests pass, including the newan_unclosed_block_at_the_end_of_input_stops, which finishes in under 10 ms with one recorded error.cargo check --manifest-path compiler/Cargo.toml --all-targets.analyzewith this change: the slowest call took 4 ms.🤖 Generated with Claude Code