From 0fae7a26628f275b403495339cafc3a467c5dd47 Mon Sep 17 00:00:00 2001 From: AurumTheEnd <47597303+aurumtheend@users.noreply.github.com> Date: Fri, 8 Mar 2024 11:40:19 +0100 Subject: [PATCH] fix(parser): fixed panic when EOL was reached while consuming a long literal name --- src/parser/tokenize.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/parser/tokenize.rs b/src/parser/tokenize.rs index 3485696..7e19803 100644 --- a/src/parser/tokenize.rs +++ b/src/parser/tokenize.rs @@ -91,12 +91,15 @@ fn tokenize_level( // move over from the initial `{`, resetting peeking pop_n_left(&mut buffer, input, 1); let mut literal_buffer: String = String::new(); + let mut did_hit_closing_brace = false; input.reset_peek(); while let Some(c) = input.peek() { if c.to_string() == IntermediateToken::LITERAL_END_PATTERN { // move over from the final `}` input.next(); + + did_hit_closing_brace = true; break; } @@ -104,6 +107,10 @@ fn tokenize_level( input.next(); } + if !did_hit_closing_brace { + return Err(TokenizeError::MissingClosingCurlyBrace); + } + // TODO return TokenizeError if builder is empty at the end (FinalToken::Literal(literal_buffer), 0) }