Status/Resolution/Reason: To Fix//BugVerified
Reporter/Name(from Bugbase): John W. / ()
Created: 10/31/2019
Components: Language, Closures
Versions: 2018
Failure Type: Non Functioning
Found In Build/Fixed In Build: 2018 update 5 /
Priority/Frequency: Normal / Some users will encounter
Locale/System: / Platforms All
Vote Count: 0
Problem Description:
The following code (or any code using the array slice syntax in an lexically scoped inner function) causes an error:
> Incompatible object argument for function call
{code}
function foo3() {
var data = [1,2,3];
return function() {
return data[::-1];
}
}
{code}
Steps to Reproduce:
Run the following code:
{code}
function foo1() {
var data = [1,2,3];
return data[::-1]; // this is fine
}
function foo2() {
var data = [1,2,3];
return function() {
return data; // this is fine
}
}
function foo3() {
var data = [1,2,3];
return function() {
// this causes compiler error
return data[::-1];
}
}
writeDump(foo1());
writeDump(foo2()());
writeDump(foo3()());
{code}
Here's a fiddle:
https://cffiddle.org/app/file?filepath=0f0206b9-24d2-4146-a52d-2293a338fbb0/6127d524-4c0a-4e84-bd4d-a770b8d5b552/9809585d-00aa-483b-99c4-ca8218e00e77.cfm
Actual Result:
(class: cftmp_cfd91c2b2db5782d47b42d881a2dee6b051c7eda2ecfm1767426690$func_CF_ANONYMOUSCLOSURE_726, method: runFunction signature: (Lcoldfusion/runtime/LocalScope;Ljava/lang/Object;Lcoldfusion/runtime/CFPage;Lcoldfusion/runtime/ArgumentCollection;)Ljava/lang/Object;) Incompatible object argument for function call
Expected Result:
Should return an array (reversed in this example but that's not important - it's the syntax that is the issue)
Any Workarounds:
Not really. You could use arraySlice function, but that doesn't allow you as many options.
Attachments:
Comments: