From 443c8cb0f865c95578949def6fe9017ad7faaef0 Mon Sep 17 00:00:00 2001 From: Kian Kasad Date: Mon, 1 Apr 2024 12:39:05 -0400 Subject: [PATCH] Don't ignore extra closing parentheses --- src/parser.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/parser.rs b/src/parser.rs index 2f030fe..3dfac5a 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -89,7 +89,13 @@ where /// /// [1]: crate::ast pub fn parse(mut self) -> Result { - Ok(extract(self.parse_expr(0, false)?)) + let result = extract(self.parse_expr(0, false)?); + if self.tokens.next().is_some() { + // The only case where this will happen is if the next token is a group close token + Err(ParseError::UnmatchedGroup) + } else { + Ok(result) + } } fn parse_expr(&mut self, min_bp: u32, accept_multi: bool) -> Result, ParseError> {