Skip to content
Snippets Groups Projects
Commit 3907a7d3 authored by Ariya Hidayat's avatar Ariya Hidayat
Browse files

Custom expression: type-checker should be aware of variadic functions (#14325)

parent 183fe665
Branches
Tags
No related merge requests found
......@@ -64,7 +64,7 @@ export function typeCheck(cst, rootType) {
const clause = CLAUSE_TOKENS.get(functionToken);
const name = functionToken.name;
const expectedArgsLength = clause.args.length;
if (clause.args.length !== args.length) {
if (!clause.multiple && clause.args.length !== args.length) {
const message = t`Function ${name} expects ${expectedArgsLength} arguments`;
this.errors.push({ message });
}
......
......@@ -85,6 +85,12 @@ describe("type-checker", () => {
expect(expr("[X]+CASE([Y],4,5)").dimensions).toEqual(["X"]);
expect(expr("[X]+CASE([Y],4,5)").segments).toEqual(["Y"]);
});
it("should allow any number of arguments in a variadic function", () => {
expect(() => validate("CONCAT('1')")).not.toThrow();
expect(() => validate("CONCAT('1','2')")).not.toThrow();
expect(() => validate("CONCAT('1','2','3')")).not.toThrow();
});
});
describe("for a filter", () => {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment