Skip to content

Commit 1f74b1b

Browse files
committed
Auto merge of #13794 - jonas-schievink:reset-step-limit-after-bump, r=jonas-schievink
fix: fix "parser seems stuck" panic when parsing colossal files The parser step count is incremented every time the parser inspects a token. It's purpose is to ensure the parser doesn't get stuck in infinite loops. But since `self.pos` grows monotonically when parsing source code, it gives a better idea for whether the parser is stuck or not: if `self.pos` is changed, we know that the parser cannot be stuck, so it is safe to reset the step count to 0. This makes the limit check scale with the size of the file, and so should fix #13788.
2 parents 9ed1829 + c110481 commit 1f74b1b

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

crates/parser/src/parser.rs

+1
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ impl<'t> Parser<'t> {
237237

238238
fn do_bump(&mut self, kind: SyntaxKind, n_raw_tokens: u8) {
239239
self.pos += n_raw_tokens as usize;
240+
self.steps.set(0);
240241
self.push_event(Event::Token { kind, n_raw_tokens });
241242
}
242243

0 commit comments

Comments
 (0)