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