summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2018-09-11 13:30:31 -0700
committerJohn Firebaugh <john.firebaugh@gmail.com>2018-09-13 13:58:20 -0700
commit041bd3cdad1304e608e1eefe86d637b3acaaa9d4 (patch)
treeda69e8a6fb4d27822e9ec150a010c6930ef84071
parentc63e628acc584aa02bb067f5714d5bcd7889f675 (diff)
downloadqtlocation-mapboxgl-041bd3cdad1304e608e1eefe86d637b3acaaa9d4.tar.gz
[core] ["to-array", <item type>, <empty array>] should work for any item type
Ports https://github.com/mapbox/mapbox-gl-js/pull/7261.
-rw-r--r--src/mbgl/style/expression/check_subtype.cpp16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/mbgl/style/expression/check_subtype.cpp b/src/mbgl/style/expression/check_subtype.cpp
index 04a1643f0c..73f7d18a34 100644
--- a/src/mbgl/style/expression/check_subtype.cpp
+++ b/src/mbgl/style/expression/check_subtype.cpp
@@ -15,11 +15,19 @@ optional<std::string> checkSubtype(const Type& expected, const Type& t) {
optional<std::string> result = expected.match(
[&] (const Array& expectedArray) -> optional<std::string> {
- if (!t.is<Array>()) { return {errorMessage(expected, t)}; }
+ if (!t.is<Array>()) {
+ return {errorMessage(expected, t)};
+ }
const auto& actualArray = t.get<Array>();
- const auto err = checkSubtype(expectedArray.itemType, actualArray.itemType);
- if (err) return { errorMessage(expected, t) };
- if (expectedArray.N && expectedArray.N != actualArray.N) return { errorMessage(expected, t) };
+ if (!actualArray.N || *actualArray.N != 0 || actualArray.itemType != type::Value) {
+ const auto err = checkSubtype(expectedArray.itemType, actualArray.itemType);
+ if (err) {
+ return { errorMessage(expected, t) };
+ }
+ }
+ if (expectedArray.N && expectedArray.N != actualArray.N) {
+ return { errorMessage(expected, t) };
+ }
return {};
},
[&] (const ValueType&) -> optional<std::string> {