Skip to content

Commit 20b0f9a

Browse files
authored
Merge pull request #2271 from xzyfer/remove/parser-ast-validation
Remove left over AST validation from the parser
2 parents 5ec71fd + 558dd71 commit 20b0f9a

File tree

2 files changed

+8
-13
lines changed

2 files changed

+8
-13
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 & 9 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();
@@ -245,10 +240,6 @@ namespace Sass {
245240
}
246241

247242
else if (lex < kwd_extend >(true)) {
248-
if (block->is_root()) {
249-
error("Extend directives may only be used within rules.", pstate);
250-
}
251-
252243
Lookahead lookahead = lookahead_for_include(position);
253244
if (!lookahead.found) css_error("Invalid CSS", " after ", ": expected selector, was ");
254245
Selector_Obj target;

0 commit comments

Comments
 (0)