proper error message for out of place @return

This commit is contained in:
ConnorSkees 2020-03-22 00:47:21 -04:00
parent 242cd7857f
commit 78d7d5ce36
2 changed files with 5 additions and 1 deletions

View File

@ -616,7 +616,7 @@ pub(crate) fn eat_expr<I: Iterator<Item = Token>>(
AtRule::Debug(a, b) => Ok(Some(Expr::Debug(a, b))),
AtRule::Warn(a, b) => Ok(Some(Expr::Warn(a, b))),
AtRule::Error(pos, err) => Err(SassError::new(err, pos)),
AtRule::Return(_) => todo!("@return in unexpected location!"),
AtRule::Return(_) => Err("This at-rule is not allowed here.".into()),
AtRule::Content => {
return Err("@content is only allowed within mixin declarations.".into())
}

View File

@ -15,3 +15,7 @@ error!(
toplevel_invalid_atrule_ident,
"@`or $i from 1 through 3 {}", "Error: Expected identifier."
);
error!(
return_as_style,
"a {@return foo;}", "Error: This at-rule is not allowed here."
);