Skip to content

Commit

Permalink
Disallow interpolation for variable-length numeric arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
Anand Thakker committed Oct 25, 2017
1 parent 4c7d0d7 commit 04943b7
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/style-spec/expression/definitions/curve.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,12 @@ class Curve implements Expression {
if (interpolation.name !== 'step' &&
outputType.kind !== 'number' &&
outputType.kind !== 'color' &&
!(outputType.kind === 'array' && outputType.itemType.kind === 'number')) {
!(
outputType.kind === 'array' &&
outputType.itemType.kind === 'number' &&
typeof outputType.N === 'number'
)
) {
return context.error(`Type ${toString(outputType)} is not interpolatable, and thus cannot be used as a ${interpolation.name} curve's output type.`);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"expression": [
"curve",
["exponential", 2],
["number", ["get", "x"]],
1,
["array", "number", ["get", "array"]],
3,
["array", "number", ["get", "array_two"]]
],
"inputs": [],
"expected": {
"compiled": {
"result": "error",
"errors": [
{
"key": "",
"error": "Type array<number> is not interpolatable, and thus cannot be used as a exponential curve's output type."
}
]
}
}
}

0 comments on commit 04943b7

Please sign in to comment.