From 93d6d4c9d116d61daae1426707a4cb3d3b6718fa Mon Sep 17 00:00:00 2001 From: Brenley Dueck Date: Sat, 14 Nov 2026 16:14:13 -0600 Subject: [PATCH] fix(parse): stop an editor's parse of an unclosed block at end of input 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. --- compiler/src/parse.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/compiler/src/parse.rs b/compiler/src/parse.rs index 52052e43..081d8d66 100644 --- a/compiler/src/parse.rs +++ b/compiler/src/parse.rs @@ -1217,11 +1217,16 @@ pub fn parse_block(c: &mut Cursor) -> R> { c.ws(true); let mut out = vec![]; while !c.starts_with("}") { + let at = c.i; out.push(parse_stmt(c)?); out.append(&mut c.pending); c.ws(true); c.eat(";"); c.ws(true); + // an editor's parse reads a missing statement as an empty one, so at the end of input nothing moves + if c.i == at { + break; + } } c.expect("}")?; Ok(out) @@ -2257,6 +2262,13 @@ mod recovering { assert!(parse_program(src).is_err()); } + #[test] + fn an_unclosed_block_at_the_end_of_input_stops() { + let src = "export default component App() {\n