allow variable declarations before and between @use

This commit is contained in:
Connor Skees 2020-08-07 02:10:51 -04:00
parent a7ccb4d6d3
commit 7a4a191d59
2 changed files with 19 additions and 3 deletions

View File

@ -241,6 +241,7 @@ impl<'a> Parser<'a> {
Comment::Loud(s) => comments.push(Stmt::Comment(s)), Comment::Loud(s) => comments.push(Stmt::Comment(s)),
} }
} }
Some(Token { kind: '$', .. }) => self.parse_variable_declaration()?,
Some(..) | None => break, Some(..) | None => break,
} }
} }

View File

@ -311,8 +311,23 @@ fn use_variable_redeclaration_private() {
fn use_variable_redeclaration_builtin() { fn use_variable_redeclaration_builtin() {
let input = "@use \"sass:math\";\nmath.$e: red;"; let input = "@use \"sass:math\";\nmath.$e: red;";
assert_err!( assert_err!("Error: Cannot modify built-in variable.", input);
"Error: Cannot modify built-in variable.", }
input
#[test]
fn use_variable_declaration_between_use() {
let input = r#"
$a: red;
$b: green;
@use "sass:math";
$b: red;
@use "sass:meta";
a {
color: $a $b;
}"#;
assert_eq!(
"a {\n color: red red;\n}\n",
&grass::from_string(input.to_string(), &grass::Options::default()).expect(input)
); );
} }