From 744dad61267db8019f61623892d29cd89848c33b Mon Sep 17 00:00:00 2001 From: Anand Krishnamoorthi <35780660+anakrish@users.noreply.github.com> Date: Thu, 25 Apr 2024 23:51:52 -0700 Subject: [PATCH] OPA Conformance: Do not interpret # within regular string (#216) fixes #213 Signed-off-by: Anand Krishnamoorthi --- src/lexer.rs | 2 +- tests/lexer/cases/comment.yaml | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/lexer.rs b/src/lexer.rs index f4ae34c..a7b02c5 100644 --- a/src/lexer.rs +++ b/src/lexer.rs @@ -455,7 +455,7 @@ impl<'source> Lexer<'source> { let (offset, ch) = self.peek(); let col = self.col + (offset - start) as u16; match ch { - '"' | '#' | '\x00' => { + '"' | '\x00' => { break; } '\\' => { diff --git a/tests/lexer/cases/comment.yaml b/tests/lexer/cases/comment.yaml index 0ec359d..4a4259e 100644 --- a/tests/lexer/cases/comment.yaml +++ b/tests/lexer/cases/comment.yaml @@ -56,11 +56,9 @@ cases: - note: comments-within-rstring rego: | - #Comments aren't allowed within strings, - "#This is not a comment - "#c - tokens: - error: unmatched " + #Comments aren't lexed within raw strings. + "#This is not a comment"#c + tokens: ["#This is not a comment", ""] - note: comment-integer-break rego: |