Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

["to-array", <item type>, <empty array>] should work for any item type #7261

Merged
merged 1 commit into from
Sep 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/style-spec/expression/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export function checkSubtype(expected: Type, t: Type): ?string {
return null;
} else if (expected.kind === 'array') {
if (t.kind === 'array' &&
!checkSubtype(expected.itemType, t.itemType) &&
((t.N === 0 && t.itemType.kind === 'value') || !checkSubtype(expected.itemType, t.itemType)) &&
(typeof expected.N !== 'number' || expected.N === t.N)) {
return null;
}
Expand Down
6 changes: 4 additions & 2 deletions test/integration/expression-tests/array/item-type/test.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"inputs": [
[{}, {"properties": {"x": ["a", "b"]}}],
[{}, {"properties": {"x": [1, 2]}}],
[{}, {"properties": {"x": [1, "b"]}}]
[{}, {"properties": {"x": [1, "b"]}}],
[{}, {"properties": {"x": []}}]
],
"expected": {
"compiled": {
Expand All @@ -19,7 +20,8 @@
},
{
"error": "Expected value to be of type array<string>, but found array<value, 2> instead."
}
},
[]
],
"serialized": ["array", "string", ["get", "x"]]
}
Expand Down