diff --git a/src/parse/mod.rs b/src/parse/mod.rs index 0fd3eb5..c8793bb 100644 --- a/src/parse/mod.rs +++ b/src/parse/mod.rs @@ -245,6 +245,13 @@ impl<'a> Parser<'a> { // dart-sass seems to special-case the error message here? '!' | '{' => return Err(("expected \"}\".", *pos).into()), _ => { + if self.flags.in_function() { + return Err(( + "Functions can only contain variable declarations and control directives.", + self.span_before + ) + .into()); + } if self.flags.in_keyframes() { match self.is_selector_or_style()? { SelectorOrStyle::Style(property, value) => { diff --git a/tests/functions.rs b/tests/functions.rs index 007dc25..973dbe0 100644 --- a/tests/functions.rs +++ b/tests/functions.rs @@ -305,3 +305,16 @@ error!( }", "Error: This at-rule is not allowed here." ); +error!( + disallows_selectors, + "@function foo($a) { + functiona { + @return $a; + } + } + + a { + color: foo(nul); + }", + "Error: Functions can only contain variable declarations and control directives." +);