Skip to content

Commit 986683b

Browse files
Fix: Synchronize parser token stream on error to prevent cascading false positives.
1 parent b327486 commit 986683b

File tree

1 file changed

+10
-0
lines changed
  • compiler/src/modules/parser

1 file changed

+10
-0
lines changed

compiler/src/modules/parser/mod.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,16 @@ impl<'src, I: Iterator<Item = Token>> Parser<'src, I> {
166166
.map(|t| (t.line, t.start, t.end))
167167
.unwrap_or((0, 0, 0));
168168
self.errors.push(Diagnostic { line, col, end, msg: msg.to_string() });
169+
170+
loop {
171+
match self.tokens.peek().map(|t| t.kind) {
172+
None
173+
| Some(TokenType::Newline)
174+
| Some(TokenType::Dedent)
175+
| Some(TokenType::Endmarker) => break,
176+
_ => { self.tokens.next(); }
177+
}
178+
}
169179
}
170180

171181
pub(super) fn at_end(&mut self) -> bool {

0 commit comments

Comments
 (0)