From 9c2d1200f797dd942064484a48ab2e0d22d7cb50 Mon Sep 17 00:00:00 2001 From: Connor Skees Date: Tue, 4 Aug 2020 02:13:15 -0400 Subject: [PATCH] allow multiline comments in functions --- src/parse/mod.rs | 6 +++++- tests/functions.rs | 12 ++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/parse/mod.rs b/src/parse/mod.rs index 81a3422..de5d5ee 100644 --- a/src/parse/mod.rs +++ b/src/parse/mod.rs @@ -232,7 +232,11 @@ impl<'a> Parser<'a> { self.whitespace(); match comment.node { Comment::Silent => continue, - Comment::Loud(s) => stmts.push(Stmt::Comment(s)), + Comment::Loud(s) => { + if !self.flags.in_function() { + stmts.push(Stmt::Comment(s)); + } + } } } '\u{0}'..='\u{8}' | '\u{b}'..='\u{1f}' => { diff --git a/tests/functions.rs b/tests/functions.rs index 973dbe0..333d4a1 100644 --- a/tests/functions.rs +++ b/tests/functions.rs @@ -318,3 +318,15 @@ error!( }", "Error: Functions can only contain variable declarations and control directives." ); +test!( + allows_multiline_comment, + "@function foo($a) { + /* foo */ + @return $a; + } + + a { + color: foo(nul); + }", + "a {\n color: nul;\n}\n" +);