Another bug with the rest operator: ```function f(...
# adobe
a
Another bug with the rest operator:
Copy code
function f(required string param1, required numeric param2, ... date param3) // does not work in CF2021. Does not error, but ignores the rest operator
Repro (https://trycf.com/gist/850662c058d620ce94f39e2c7e43737b/acf2021?theme=monokai):
Copy code
function f(required string param1, required numeric param2, ... date param3) {
    return arguments
}


result = f("a string", 42, createDate(2011,3,24), createDate(2016, 8, 17))
writeDump(var=result, label="actual")

expected = {
    param1 = "a string",
    param2 = 42,
    param3 = [createDate(2011,3,24), createDate(2016, 8, 17)]
}
writeDump(var=expected, label="expected")

https://i2.paste.pics/88ef751197cd12fa1ea2ed1afb7b4f88.png

p
But technically you're passing in a 4th param and the 3rd is not an array its scoped as a date nor passed in as an array. Not sure I understand the error/bug.
t
The Rest Operator (
...
) is a new syntax in CF2021.
the Rest syntax collects and condenses [iterables] into a single element
It's supposed to take everything passed to the function starting at
...
and group them into an array referenced by
param3
. It's not.
messing with the code, it's not allowed to be typed? Is that really what's going on?
p
Oh I missed that, gotcha
t
If you take out
date
it works as expected... And similarly, if you change it to string (and change the inputs accordingly) it fails in the same way.
a
Well yeah... but I specifically want an array of dates
t
Yeah, sorry. that' wasn't meant to be a solution - more of a "you have got to be kidding me"