From d0513a6c5d354e0b5ad3fab7ecd235c701fd7915 Mon Sep 17 00:00:00 2001 From: Turings98apprentice <34955634+Turings98apprentice@users.noreply.github.com> Date: Sat, 18 Oct 2025 04:10:48 -0400 Subject: [PATCH 1/2] fix(signature): Enable the use of repeating parameters in lambda functions Before this change, a function signature containing a repeating symbol (eg. ) would copy the first of those arguments into every matching parameter (eg. `function($a1, $a2){[$a1, $a2]}(1, 2)` returns [1, 1] instead of [1, 2]) instead of copying each argument to each parameter respectively. --- src/signature.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/signature.js b/src/signature.js index f0972773..d0eb4e41 100644 --- a/src/signature.js +++ b/src/signature.js @@ -252,15 +252,15 @@ const signature = (() => { argIndex++; } } else { - // may have matched multiple args (if the regex ends with a '+' + // may have matched multiple args (if the regex ends with a '+') // split into single tokens match.split('').forEach(function (single) { + arg = args[argIndex]; if (param.type === 'a') { if (single === 'm') { // missing (undefined) arg = undefined; } else { - arg = args[argIndex]; var arrayOK = true; // is there type information on the contents of the array? if (typeof param.subtype !== 'undefined') { From 5ed51a67dc1f116c00f5dc28111f4939fe9be316 Mon Sep 17 00:00:00 2001 From: Turings98apprentice <34955634+Turings98apprentice@users.noreply.github.com> Date: Sat, 18 Oct 2025 04:33:14 -0400 Subject: [PATCH 2/2] test(signature): Add tests for variadic lambda functions "Variadic" just means a function can take an arbitrary number of arguments (eg. ). One important note here is that this implementation doesn't actually support an arbitrary number of arguments, only as many as the number of parameters you're willing to add to your function. I tried to change as little as possible while still squashing the bug. I would recommend a breaking change that would bind each repeating parameter to an array of its provided arguments. Then, you could write something like this: `function($nums, $str){{$str: $count($nums)}}` --- case035.json | 9 +++++++++ case036.json | 6 ++++++ case037.json | 6 ++++++ case038.json | 6 ++++++ case039.json | 9 +++++++++ case040.json | 6 ++++++ 6 files changed, 42 insertions(+) create mode 100644 case035.json create mode 100644 case036.json create mode 100644 case037.json create mode 100644 case038.json create mode 100644 case039.json create mode 100644 case040.json diff --git a/case035.json b/case035.json new file mode 100644 index 00000000..d2a1a5c8 --- /dev/null +++ b/case035.json @@ -0,0 +1,9 @@ +{ + "expr": "λ($arg1, $arg2){{\"$arg1\": $arg1, \"$arg2\": $arg2}}(1, 2, 3)", + "dataset": null, + "bindings": {}, + "result": { + "$arg1": 1, + "$arg2": 2 + } +} \ No newline at end of file diff --git a/case036.json b/case036.json new file mode 100644 index 00000000..bcaca8ff --- /dev/null +++ b/case036.json @@ -0,0 +1,6 @@ +{ + "expr": "λ($arg1, $arg2, $arg3)>{[$arg1, $arg2, $arg3]}(1, 2, \"a\")", + "dataset": null, + "bindings": {}, + "result": [1, 2, "a"] +} \ No newline at end of file diff --git a/case037.json b/case037.json new file mode 100644 index 00000000..2ca5fb32 --- /dev/null +++ b/case037.json @@ -0,0 +1,6 @@ +{ + "expr": "λ($arg1, $arg2, $arg3)>{[$arg1, $arg2, $arg3]}(1, 2, \"a\")", + "data": "b", + "bindings": {}, + "result": [1, 2, "a"] +} \ No newline at end of file diff --git a/case038.json b/case038.json new file mode 100644 index 00000000..f7491da5 --- /dev/null +++ b/case038.json @@ -0,0 +1,6 @@ +{ + "expr": "λ($arg1, $arg2, $arg3)>{[$arg1, $arg2, $arg3]}(1, 2)", + "data": "b", + "bindings": {}, + "result": [1, 2, "b"] +} \ No newline at end of file diff --git a/case039.json b/case039.json new file mode 100644 index 00000000..d891867f --- /dev/null +++ b/case039.json @@ -0,0 +1,9 @@ +{ + "expr": "λ($arg1, $arg2)+:o>{{'$arg1': $arg1, '$arg2': $arg2}}([1, 2], [3, 4], [5, 6])", + "data": "b", + "bindings": {}, + "result": { + "$arg1": [1, 2], + "$arg2": [3, 4] + } +} \ No newline at end of file diff --git a/case040.json b/case040.json new file mode 100644 index 00000000..25199bd4 --- /dev/null +++ b/case040.json @@ -0,0 +1,6 @@ +{ + "expr": "λ($arg1, $arg2)>{[$arg1, $arg2]}(1, 2, 3)", + "dataset": null, + "bindings": {}, + "result": [1, 2] +} \ No newline at end of file