Skip to content

Commit

Permalink
fix: use peek_char instead of next_char
Browse files Browse the repository at this point in the history
  • Loading branch information
creampnx-x committed Sep 24, 2022
1 parent 20f3c49 commit a70520f
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion boa_engine/src/syntax/lexer/comment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,13 @@ impl<R> Tokenizer<R> for SingleLineComment {
let _timer = Profiler::global().start_event("SingleLineComment", "Lexing");

// Skip either to the end of the line or to the end of the input
while let Some(ch) = cursor.next_char()? {
while let Some(ch) = cursor.peek_char()? {
let tried_ch = char::try_from(ch);
match tried_ch {
Ok(c) if c == '\r' || c == '\n' || c == '\u{2028}' || c == '\u{2029}' => break,
_ => {}
};
cursor.next_char().expect("Comment character vanished");
}
Ok(Token::new(
TokenKind::Comment,
Expand Down

0 comments on commit a70520f

Please sign in to comment.