Skip to content

Commit 50167c2

Browse files
committed
Remove function child node validation from parser
The check nesting visitor is responsible for AST validation. This was left over from #2062. Also fixed a bug that caused the function child node validation to be skipped.
1 parent 5ec71fd commit 50167c2

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

src/check_nesting.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,10 @@ namespace Sass {
8282
Statement_Ptr CheckNesting::operator()(Definition_Ptr n)
8383
{
8484
if (!this->should_visit(n)) return NULL;
85-
if (!is_mixin(n)) return n;
85+
if (!is_mixin(n)) {
86+
visit_children(n);
87+
return n;
88+
}
8689

8790
Definition_Ptr old_mixin_definition = this->current_mixin_definition;
8891
this->current_mixin_definition = n;
@@ -129,9 +132,8 @@ namespace Sass {
129132
if (SASS_MEMORY_CAST_PTR(Declaration, node))
130133
{ this->invalid_prop_parent(this->parent); }
131134

132-
if (
133-
SASS_MEMORY_CAST_PTR(Declaration, this->parent)
134-
) { this->invalid_prop_child(node); }
135+
if (SASS_MEMORY_CAST_PTR(Declaration, this->parent))
136+
{ this->invalid_prop_child(node); }
135137

136138
if (SASS_MEMORY_CAST_PTR(Return, node))
137139
{ this->invalid_return_parent(this->parent); }
@@ -258,6 +260,8 @@ namespace Sass {
258260
SASS_MEMORY_CAST_PTR(Debug, child) ||
259261
SASS_MEMORY_CAST_PTR(Return, child) ||
260262
SASS_MEMORY_CAST_PTR(Variable, child) ||
263+
// Ruby Sass doesn't distinguish variables and assignments
264+
SASS_MEMORY_CAST_PTR(Assignment, child) ||
261265
SASS_MEMORY_CAST_PTR(Warning, child) ||
262266
SASS_MEMORY_CAST_PTR(Error, child)
263267
)) {

src/parser.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -222,11 +222,6 @@ namespace Sass {
222222
else if (lex < kwd_while_directive >(true)) { block->append(&parse_while_directive()); }
223223
else if (lex < kwd_return_directive >(true)) { block->append(&parse_return_directive()); }
224224

225-
// abort if we are in function context and have nothing parsed yet
226-
else if (stack.back() == Scope::Function) {
227-
error("Functions can only contain variable declarations and control directives.", pstate);
228-
}
229-
230225
// parse imports to process later
231226
else if (lex < kwd_import >(true)) {
232227
Scope parent = stack.empty() ? Scope::Rules : stack.back();

0 commit comments

Comments
 (0)