Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
Fix style parsing bug for constant expressions
Browse files Browse the repository at this point in the history
Closes #10849
  • Loading branch information
Anand Thakker committed Apr 5, 2018
1 parent 275d753 commit 26a461f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
14 changes: 11 additions & 3 deletions include/mbgl/style/conversion/data_driven_property_value.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,17 @@ struct Converter<DataDrivenPropertyValue<T>> {
} else {
// If an expression is neither zoom- nor feature-dependent, it
// should have been reduced to a Literal when it was parsed.
auto literal = dynamic_cast<Literal*>(expression->get());
assert(literal);
optional<T> constant = fromExpressionValue<T>(literal->getValue());
optional<T> constant;
if (auto literal = dynamic_cast<Literal*>(expression->get())) {
// cool, it's pre-folded to a literal
constant = fromExpressionValue<T>(literal->getValue());
} else {
// we didn't manage to fold to a literal during parsing, so evaluate it now
EvaluationContext params(nullptr);
EvaluationResult evaluated((*expression)->evaluate(params));
assert(evaluated);
constant = fromExpressionValue<T>(*evaluated);
}
if (!constant) {
return {};
}
Expand Down

0 comments on commit 26a461f

Please sign in to comment.