Skip to content

Commit 2c75e9b

Browse files
committed
Fix MSVC issue (invalid selector schema use as statement)
1 parent 734668f commit 2c75e9b

File tree

3 files changed

+21
-7
lines changed

3 files changed

+21
-7
lines changed

src/ast.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ namespace Sass {
396396
ADD_PROPERTY(bool, group_end)
397397
public:
398398
Statement(ParserState pstate, Statement_Type st = NONE, size_t t = 0)
399-
: AST_Node(pstate), statement_type_(st), tabs_(t), group_end_(false)
399+
: AST_Node(pstate), block_(0), statement_type_(st), tabs_(t), group_end_(false)
400400
{ }
401401
virtual ~Statement() = 0;
402402
// needed for rearranging nested rulesets during CSS emission

src/cssize.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,20 @@ namespace Sass {
102102
{
103103
p_stack.push_back(r);
104104
s_stack.push_back(dynamic_cast<Selector_List*>(r->selector()));
105+
// this can return a string schema
106+
// string schema is not a statement!
107+
// r->block() is already a string schema
108+
// and that is comming from propset expand
109+
Statement* stmt = r->block()->perform(this);
110+
// this should protect us (at least a bit) from our mess
111+
// fixing this properly is harder that it should be ...
112+
if (dynamic_cast<Statement*>((AST_Node*)stmt) == NULL) {
113+
error("Illegal nesting: Only properties may be nested beneath properties.", r->block()->pstate());
114+
}
105115
Ruleset* rr = SASS_MEMORY_NEW(ctx.mem, Ruleset,
106116
r->pstate(),
107117
r->selector(),
108-
r->block()->perform(this)->block());
118+
stmt->block());
109119
rr->is_root(r->is_root());
110120
// rr->tabs(r->block()->tabs());
111121
s_stack.pop_back();

src/expand.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -153,20 +153,24 @@ namespace Sass {
153153
return rr;
154154
}
155155

156+
// this is not properly implemented
157+
// mixes string_schema and statement
156158
Statement* Expand::operator()(Propset* p)
157159
{
158160
property_stack.push_back(p->property_fragment());
159161
Block* expanded_block = p->block()->perform(this)->block();
160-
161162
for (size_t i = 0, L = expanded_block->length(); i < L; ++i) {
162163
Statement* stm = (*expanded_block)[i];
163164
if (Declaration* dec = static_cast<Declaration*>(stm)) {
165+
// dec = SASS_MEMORY_NEW(ctx.mem, Declaration, *dec);
164166
String_Schema* combined_prop = SASS_MEMORY_NEW(ctx.mem, String_Schema, p->pstate());
165167
if (!property_stack.empty()) {
166-
*combined_prop << property_stack.back()->perform(&eval)
167-
<< SASS_MEMORY_NEW(ctx.mem, String_Quoted,
168-
p->pstate(), "-")
169-
<< dec->property(); // TODO: eval the prop into a string constant
168+
*combined_prop << property_stack.back()->perform(&eval);
169+
*combined_prop << SASS_MEMORY_NEW(ctx.mem, String_Quoted, p->pstate(), "-");
170+
if (dec->property()) {
171+
// we cannot directly add block (from dec->property()) to string schema (combined_prop)
172+
*combined_prop << SASS_MEMORY_NEW(ctx.mem, String_Quoted, dec->pstate(), dec->property()->to_string());
173+
}
170174
}
171175
else {
172176
*combined_prop << dec->property();

0 commit comments

Comments
 (0)