Skip to content

Commit 803868d

Browse files
committed
Fix index increment in Signature validation
1 parent e164d24 commit 803868d

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

src/jsonata/signature.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,7 @@ def validate(self, args: Any, context: Optional[Any]) -> Optional[Any]:
308308
arg = args[arg_index] if arg_index < len(args) else None
309309
validated_args.append(arg)
310310
arg_index += 1
311+
index += 1
311312
return validated_args
312313
self.throw_validation_error(args, supplied_sig, self.function_name)
313314

tests/signature_test.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ class TestSignature:
77
def test_parameters_are_converted_to_arrays(self):
88
expr = jsonata.Jsonata("$greet(1,null,3)")
99
expr.register_function("greet", jsonata.Jsonata.JFunction(TestSignature.JFunctionCallable1(), "<a?a?a?a?:s>"))
10-
assert expr.evaluate(None) == "[[1], [null], [3], [None]]"
10+
assert expr.evaluate(None) == "[[1], None, [3], None]"
1111

1212
class JFunctionCallable1(jsonata.Jsonata.JFunctionCallable):
1313

@@ -30,3 +30,13 @@ class JFunctionCallable2(jsonata.Jsonata.JFunctionCallable):
3030

3131
def call(self, input, args):
3232
return None
33+
34+
def test_var_arg_many(self):
35+
expr = jsonata.Jsonata("$customArgs('test',[1,2,3,4],3)")
36+
expr.register_function("customArgs", jsonata.Jsonata.JFunction(TestSignature.JFunctionCallable3(), "<sa<n>n:s>"))
37+
assert expr.evaluate(None) == "['test', [1, 2, 3, 4], 3]"
38+
39+
class JFunctionCallable3(jsonata.Jsonata.JFunctionCallable):
40+
41+
def call(self, input, args):
42+
return str(args)

0 commit comments

Comments
 (0)