diff --git a/src/style-spec/validate/validate_function.js b/src/style-spec/validate/validate_function.js index f34303a06dc..e38ccce1f29 100644 --- a/src/style-spec/validate/validate_function.js +++ b/src/style-spec/validate/validate_function.js @@ -5,7 +5,8 @@ import validate from './validate'; import validateObject from './validate_object'; import validateArray from './validate_array'; import validateNumber from './validate_number'; -import { unbundle } from '../util/unbundle_jsonlint'; +import { isExpression } from '../expression'; +import { unbundle, deepUnbundle } from '../util/unbundle_jsonlint'; import { supportsPropertyExpression, supportsZoomExpression, @@ -138,6 +139,10 @@ export default function validateFunction(options) { }, value)); } + if (isExpression(deepUnbundle(value[1]))) { + return errors.concat([new ValidationError(`${key}[1]`, value[1], 'expressions are not allowed in function stops.')]); + } + return errors.concat(validate({ key: `${key}[1]`, value: value[1], diff --git a/test/unit/style-spec/fixture/functions.input.json b/test/unit/style-spec/fixture/functions.input.json index 82bc2a06e2c..68c63fda0ad 100644 --- a/test/unit/style-spec/fixture/functions.input.json +++ b/test/unit/style-spec/fixture/functions.input.json @@ -967,6 +967,25 @@ "layout": { "line-join": [ "coalesce", ["feature-state", "myState"], "bevel"] } + }, { + "id": "invalid function - expression as stop value", + "type": "line", + "source": "source", + "source-layer": "layer", + "paint": { + "line-width": { + "base": 1, + "stops": [ + [ + 6, + [ + "literal", + 3 + ] + ] + ] + } } + } ] } diff --git a/test/unit/style-spec/fixture/functions.output.json b/test/unit/style-spec/fixture/functions.output.json index c7685c8d7a1..87ec1996fe4 100644 --- a/test/unit/style-spec/fixture/functions.output.json +++ b/test/unit/style-spec/fixture/functions.output.json @@ -198,5 +198,9 @@ { "message": "layers[55].layout.line-join: \"feature-state\" data expressions are not supported with layout properties.", "line": 968 + }, + { + "message": "layers[56].paint.line-width.stops[0][1]: expressions are not allowed in function stops.", + "line": 981 } -] \ No newline at end of file +]