Allow function declarations inside rulesets

This commit is contained in:
ConnorSkees 2020-03-19 20:01:13 -04:00
parent 195a9b1552
commit 3919e92dcb
3 changed files with 12 additions and 2 deletions

View File

@ -64,7 +64,7 @@ impl Function {
return Err("unexpected EOF (TODO: better error message)".into()); return Err("unexpected EOF (TODO: better error message)".into());
} }
} }
devour_whitespace(toks);
Ok((name, Function::new(scope, args, body))) Ok((name, Function::new(scope, args, body)))
} }

View File

@ -53,3 +53,13 @@ test!(
"$x: 0;\na {\n color: if($x != 0, a, b);\n}\n", "$x: 0;\na {\n color: if($x != 0, a, b);\n}\n",
"a {\n color: b;\n}\n" "a {\n color: b;\n}\n"
); );
test!(
function_decl_in_ruleset,
"a {\n @function foo() {\n @return 3;\n }\n color: foo();\n}\n",
"a {\n color: 3;\n}\n"
);
test!(
function_decl_in_foreign_ruleset,
"a {\n @function foo() {\n @return 3;\n }\n}\nb {\n color: foo();\n}\n",
"b {\n color: foo();\n}\n"
);