From df93047d405d17f86d54c6784e3664436085deb3 Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Tue, 11 Sep 2018 13:30:31 -0700 Subject: [core] ["to-array", , ] should work for any item type Ports https://github.com/mapbox/mapbox-gl-js/pull/7261. --- src/mbgl/style/expression/check_subtype.cpp | 16 ++++++++++++---- 1 file 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 checkSubtype(const Type& expected, const Type& t) { optional result = expected.match( [&] (const Array& expectedArray) -> optional { - if (!t.is()) { return {errorMessage(expected, t)}; } + if (!t.is()) { + return {errorMessage(expected, t)}; + } const auto& actualArray = t.get(); - 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 { -- cgit v1.2.1