Skip to content

Commit

Permalink
Fix MSVC issue (invalid selector schema use as statement)
Browse files Browse the repository at this point in the history
  • Loading branch information
mgreter committed Apr 30, 2016
1 parent 734668f commit 2b66889
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/ast.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ namespace Sass {
ADD_PROPERTY(bool, group_end)
public:
Statement(ParserState pstate, Statement_Type st = NONE, size_t t = 0)
: AST_Node(pstate), statement_type_(st), tabs_(t), group_end_(false)
: AST_Node(pstate), block_(0), statement_type_(st), tabs_(t), group_end_(false)
{ }
virtual ~Statement() = 0;
// needed for rearranging nested rulesets during CSS emission
Expand Down
10 changes: 9 additions & 1 deletion src/cssize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,18 @@ namespace Sass {
{
p_stack.push_back(r);
s_stack.push_back(dynamic_cast<Selector_List*>(r->selector()));
// this can return a string schema
// string schema is not a statement!
Statement* stmt = r->block()->perform(this);
// this should protect us (at least a bit) from our mess
// fixing this properly is harder that it should be ...
if (dynamic_cast<Statement*>((AST_Node*)stmt) == NULL) {
error("Illegal nesting: Only properties may be nested beneath properties.", r->block()->pstate());
}
Ruleset* rr = SASS_MEMORY_NEW(ctx.mem, Ruleset,
r->pstate(),
r->selector(),
r->block()->perform(this)->block());
stmt->block());
rr->is_root(r->is_root());
// rr->tabs(r->block()->tabs());
s_stack.pop_back();
Expand Down
11 changes: 6 additions & 5 deletions src/expand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,16 +157,17 @@ namespace Sass {
{
property_stack.push_back(p->property_fragment());
Block* expanded_block = p->block()->perform(this)->block();

for (size_t i = 0, L = expanded_block->length(); i < L; ++i) {
Statement* stm = (*expanded_block)[i];
if (Declaration* dec = static_cast<Declaration*>(stm)) {
String_Schema* combined_prop = SASS_MEMORY_NEW(ctx.mem, String_Schema, p->pstate());
if (!property_stack.empty()) {
*combined_prop << property_stack.back()->perform(&eval)
<< SASS_MEMORY_NEW(ctx.mem, String_Quoted,
p->pstate(), "-")
<< dec->property(); // TODO: eval the prop into a string constant
*combined_prop << property_stack.back()->perform(&eval);
*combined_prop << SASS_MEMORY_NEW(ctx.mem, String_Quoted, p->pstate(), "-");
if (dec->property()) {
// we cannot directly add block (from dec->property()) to string schema (combined_prop)
*combined_prop << SASS_MEMORY_NEW(ctx.mem, String_Quoted, dec->pstate(), dec->property()->to_string());
}
}
else {
*combined_prop << dec->property();
Expand Down

0 comments on commit 2b66889

Please sign in to comment.