From 8ae39173ff73e4d870c06c10a6ef39e4fb09f30f Mon Sep 17 00:00:00 2001 From: Marcel Greter Date: Fri, 8 May 2015 02:38:08 +0200 Subject: [PATCH] Fix some edge case with parent selector evaluation Fixes https://github.com/sass/libsass/issues/1170 --- debugger.hpp | 3 +++ eval.cpp | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/debugger.hpp b/debugger.hpp index 5e7bee38b2..d545930e57 100644 --- a/debugger.hpp +++ b/debugger.hpp @@ -264,6 +264,9 @@ inline void debug_ast(AST_Node* node, string ind = "", Env* env = 0) cerr << ind << "If " << block; cerr << " (" << pstate_source_position(node) << ")"; cerr << " " << block->tabs() << endl; + debug_ast(block->predicate(), ind + " = "); + debug_ast(block->consequent(), ind + " <>"); + debug_ast(block->alternative(), ind + " ><"); } else if (dynamic_cast(node)) { Return* block = dynamic_cast(node); cerr << ind << "Return " << block; diff --git a/eval.cpp b/eval.cpp index acd5559a51..f277f0e44b 100644 --- a/eval.cpp +++ b/eval.cpp @@ -1047,9 +1047,13 @@ namespace Sass { Expression* Eval::operator()(Parent_Selector* p) { + // no idea why both calls are needed Selector* s = p->perform(contextualize); + if (!s) s = p->selector()->perform(contextualize); // access to parent selector may return 0 Selector_List* l = static_cast(s); + // some spec tests cause this (might be a valid case!) + // if (!s) { cerr << "Parent Selector eval error" << endl; } if (!s) { l = new (ctx.mem) Selector_List(p->pstate()); } return l->perform(listize); }