Function signature fix for repeating arguments #760
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Before this change, a function signature containing a repeating symbol (eg.
<n+>) would copy the first of those arguments into every matching parameter instead of copying each argument to each parameter respectively.Example:
returns
[1, 1]instead of[1, 2].This fix modifies the behavior to match what's expected*:
now yields
{ "Mersenne primes": [ 3, 7, 31 ] }*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.
Relatedly, 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:
which would yield
{ "Number of arguments": 5 }Signed-off-by: Brandon Peterson [email protected]