From c27b9e2b0fad9fa3c68837ba12f0b32774daaf67 Mon Sep 17 00:00:00 2001 From: Heinenen <37484430+Heinenen@users.noreply.github.com> Date: Sat, 30 Dec 2023 14:01:05 +0100 Subject: [PATCH] Don't allow nested line comment inside block comment (#3048) --- crates/typst-syntax/src/lexer.rs | 4 ---- tests/typ/compiler/comment.typ | 11 ++++++----- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/crates/typst-syntax/src/lexer.rs b/crates/typst-syntax/src/lexer.rs index 156f9404..ecb800ba 100644 --- a/crates/typst-syntax/src/lexer.rs +++ b/crates/typst-syntax/src/lexer.rs @@ -145,10 +145,6 @@ impl Lexer<'_> { depth += 1; '_' } - ('/', '/') => { - self.line_comment(); - '_' - } _ => c, } } diff --git a/tests/typ/compiler/comment.typ b/tests/typ/compiler/comment.typ index fcab3352..31025de6 100644 --- a/tests/typ/compiler/comment.typ +++ b/tests/typ/compiler/comment.typ @@ -17,13 +17,14 @@ C/* // End of block comment in line comment. // Hello */ -// Nested line comment. -/*//*/ -Still comment. -*/ - +// Nested "//" doesn't count as line comment. +/* // */ E +/*//*/ +This is a comment. +*/*/ + --- // End should not appear without start. // Error: 7-9 unexpected end of block comment