From 8ed540ea7b90d29e1d0947f9a421f36ab9bc66b2 Mon Sep 17 00:00:00 2001 From: Anand Thakker Date: Fri, 2 Mar 2018 16:38:46 -0500 Subject: [PATCH] Port fix for "at" expression off-by-1 error (#11375) * Port fix for "at" expression off-by-1 error Refs https://github.com/mapbox/mapbox-gl-js/pull/6269 * Consistency * Add ignores for symbol positiong differences in real-world tests --- mapbox-gl-js | 2 +- platform/node/test/ignores.json | 3 +++ src/mbgl/style/expression/at.cpp | 14 ++++++++++---- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/mapbox-gl-js b/mapbox-gl-js index f87d7e340..703bb35eb 160000 --- a/mapbox-gl-js +++ b/mapbox-gl-js @@ -1 +1 @@ -Subproject commit f87d7e3401af5902a1d9e6ded2600aa21e4c633f +Subproject commit 703bb35eb35ab045f2e90af2aa29d985474db293 diff --git a/platform/node/test/ignores.json b/platform/node/test/ignores.json index 50e2aa1d6..da79ac8a4 100644 --- a/platform/node/test/ignores.json +++ b/platform/node/test/ignores.json @@ -25,6 +25,9 @@ "render-tests/geojson/inline-polygon-symbol": "behavior needs reconciliation with gl-js", "render-tests/mixed-zoom/z10-z11": "https://github.com/mapbox/mapbox-gl-native/issues/10397", "render-tests/raster-masking/overlapping-zoom": "https://github.com/mapbox/mapbox-gl-native/issues/10195", + "render-tests/real-world/bangkok": "https://github.com/mapbox/mapbox-gl-native/issues/10412", + "render-tests/real-world/chicago": "https://github.com/mapbox/mapbox-gl-native/issues/10412", + "render-tests/real-world/sanfrancisco": "https://github.com/mapbox/mapbox-gl-native/issues/10412", "render-tests/regressions/mapbox-gl-js#2305": "https://github.com/mapbox/mapbox-gl-native/issues/6927", "render-tests/regressions/mapbox-gl-js#2467": "https://github.com/mapbox/mapbox-gl-native/issues/10619", "render-tests/regressions/mapbox-gl-js#2762": "https://github.com/mapbox/mapbox-gl-native/issues/10619", diff --git a/src/mbgl/style/expression/at.cpp b/src/mbgl/style/expression/at.cpp index e447d33bc..725e5ddb5 100644 --- a/src/mbgl/style/expression/at.cpp +++ b/src/mbgl/style/expression/at.cpp @@ -19,15 +19,21 @@ EvaluationResult At::evaluate(const EvaluationContext& params) const { const auto i = evaluatedIndex->get(); const auto inputArray = evaluatedInput->get>(); - if (i < 0 || i >= inputArray.size()) { + if (i < 0) { return EvaluationError { - "Array index out of bounds: " + stringify(i) + - " > " + util::toString(inputArray.size()) + "." + "Array index out of bounds: " + util::toString(i) + " < 0." + }; + } + + if (i >= inputArray.size()) { + return EvaluationError { + "Array index out of bounds: " + util::toString(i) + + " > " + util::toString(inputArray.size() - 1) + "." }; } if (i != std::floor(i)) { return EvaluationError { - "Array index must be an integer, but found " + stringify(i) + " instead." + "Array index must be an integer, but found " + util::toString(i) + " instead." }; } return inputArray[static_cast(i)];