diff --git a/packages/xpath/src/evaluator/functions/FunctionImplementation.ts b/packages/xpath/src/evaluator/functions/FunctionImplementation.ts index 8b973d665..6d164f7cd 100644 --- a/packages/xpath/src/evaluator/functions/FunctionImplementation.ts +++ b/packages/xpath/src/evaluator/functions/FunctionImplementation.ts @@ -39,7 +39,7 @@ export class InvalidArgumentError extends Error { } } -export type ParameterArityType = 'optional' | 'required' | 'variadic'; +export type ParameterArityType = 'optional' | 'required' | 'variadic' | 'variadic+' ; export type ParameterTypeHint = // | 'lazy' // TODO: it might be good to *explicitly* mark certain parameters @@ -127,6 +127,12 @@ export class FunctionImplementation { max: Infinity, }; + case 'variadic+': + return { + min: acc.min + 1, + max: Infinity, + }; + default: throw new UnreachableError(arityType); } diff --git a/packages/xpath/src/functions/xforms/geo.ts b/packages/xpath/src/functions/xforms/geo.ts index 1414847cd..48146ea4c 100644 --- a/packages/xpath/src/functions/xforms/geo.ts +++ b/packages/xpath/src/functions/xforms/geo.ts @@ -202,7 +202,7 @@ const sum = (values: readonly number[]) => { export const distance = new NumberFunction( 'distance', - [{ arityType: 'variadic' }], + [{ arityType: 'variadic+' }], (context, args) => { const lines = evaluateLines(context, args); diff --git a/packages/xpath/test/xforms/area.test.ts b/packages/xpath/test/xforms/geo.test.ts similarity index 99% rename from packages/xpath/test/xforms/area.test.ts rename to packages/xpath/test/xforms/geo.test.ts index 1adcf1da7..8d9f5eae8 100644 --- a/packages/xpath/test/xforms/area.test.ts +++ b/packages/xpath/test/xforms/geo.test.ts @@ -43,7 +43,7 @@ describe('distance() and area() functions', () => { }); }); - describe('area with nodes', () => { + describe('area and distance with nodes', () => { beforeEach(() => { testContext = createXFormsTestContext(`