fix: Fix stack overflow in parse_subexpr (#1410)

This commit is contained in:
Emil Ejbyfeldt 2024-09-06 16:17:20 +02:00 committed by GitHub
parent aa714e3447
commit 4875dadbf5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 8 additions and 1 deletions

View file

@ -897,12 +897,12 @@ impl<'a> Parser<'a> {
/// Parse a new expression.
pub fn parse_expr(&mut self) -> Result<Expr, ParserError> {
let _guard = self.recursion_counter.try_decrease()?;
self.parse_subexpr(self.dialect.prec_unknown())
}
/// Parse tokens until the precedence changes.
pub fn parse_subexpr(&mut self, precedence: u8) -> Result<Expr, ParserError> {
let _guard = self.recursion_counter.try_decrease()?;
debug!("parsing expr");
let mut expr = self.parse_prefix()?;
debug!("prefix: {:?}", expr);