From 78d7d5ce361195050779fdc59616f1c3c8069383 Mon Sep 17 00:00:00 2001 From: ConnorSkees <39542938+ConnorSkees@users.noreply.github.com> Date: Sun, 22 Mar 2020 00:47:21 -0400 Subject: [PATCH] proper error message for out of place @return --- src/lib.rs | 2 +- tests/error.rs | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index f61657f..ad6a0b6 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -616,7 +616,7 @@ pub(crate) fn eat_expr>( 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()) } diff --git a/tests/error.rs b/tests/error.rs index 34c91e1..2c4a765 100644 --- a/tests/error.rs +++ b/tests/error.rs @@ -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." +);