You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
Repository navigation
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
Style parsing fails for constant expression values #10849
changed the title [-]Assertion failed: (false), function operator(), src/mbgl/style/expression/find_zoom_curve.cpp, line 65.[/-][+]Style parsing fails for constant expression values[/+]on Feb 22, 2018
The issue here is that in Converter<DataDrivenPropertyValue<T>>, we're assuming that any expression value must be a camera, source, or composite expression.
["to-color", ["get", "x", ["literal", {"x": "red"}]] -- because we add the to-color annotation before checking isConstant() (and isConstant assumes that all of its argument's children have already been folded to literals if possible)
["let", "x", 1, ["var", "x"]] -- because we conservatively just bail out of isConstant when we see a var expression
The quick fix would be to replace the last three lines above with:
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((*parsed)->evaluate(params));
assert(evaluated); // this assert really should work, since we've already checked above that the expression is zoom- & feature-constant.
constant = fromExpressionValue<T>(*evaluated);
}
The fuller fix would be to fix constant folding during parsing to work during every case.
Activity
[-]Assertion failed: (false), function operator(), src/mbgl/style/expression/find_zoom_curve.cpp, line 65.[/-][+]Style parsing fails for constant expression values[/+]anandthakker commentedon Feb 22, 2018
The issue here is that in
Converter<DataDrivenPropertyValue<T>>, we're assuming that any expression value must be a camera, source, or composite expression.Add regression test for mapbox/mapbox-gl-native#10849
Correctly parse constant expressions in dds style properties
Correctly parse constant expressions in dds style properties (#11282)
Add regression test for mapbox/mapbox-gl-native#10849
Add regression test for mapbox/mapbox-gl-native#10849 (#6211)
anandthakker commentedon Apr 5, 2018
#11282 did not fully fix this issue. The assertion in
mapbox-gl-native/include/mbgl/style/conversion/data_driven_property_value.hpp
Lines 40 to 51 in c50a74d
fails in the following cases:
["to-color", ["get", "x", ["literal", {"x": "red"}]]-- because we add theto-colorannotation before checkingisConstant()(andisConstantassumes that all of its argument's children have already been folded to literals if possible)["let", "x", 1, ["var", "x"]]-- because we conservatively just bail out ofisConstantwhen we see avarexpressionThe quick fix would be to replace the last three lines above with:
The fuller fix would be to fix constant folding during parsing to work during every case.
Add variations to constant expression test
Fix style parsing bug for constant expressions
Add variations to constant expression test
Add variations to constant expression test
Fix constant folding (#6468)
Fix style parsing bug for constant expressions (#11606)
anandthakker commentedon Apr 10, 2018
Fixed in #11606