From 36c7b4afc3942318c0c861329bae5e8a75d8f85c Mon Sep 17 00:00:00 2001 From: xzyfer Date: Sat, 16 Mar 2019 18:37:56 +1100 Subject: [PATCH] Fix context-exists inside control blocks It's not enough to check the head of the stack to determine if we're within a mixin. Spec https://github.com/sass/sass-spec/pull/1361 Fixes #2842 --- src/parser.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/parser.cpp b/src/parser.cpp index c74e15f482..45555816a6 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -2200,7 +2200,8 @@ namespace Sass { lex< identifier >(); std::string name(lexed); - if (Util::normalize_underscores(name) == "content-exists" && stack.back() != Scope::Mixin) + bool in_mixin = std::find(stack.begin(), stack.end(), Scope::Mixin) != stack.end(); + if (Util::normalize_underscores(name) == "content-exists" && !in_mixin) { error("Cannot call content-exists() except within a mixin."); } ParserState call_pos = pstate;