dswitzer
03/16/2022, 1:56 PM<cfscript>
function test(){
var local = {modified=""};
return local.modified;
}
writeDump(test());
</cfscript>
When you run the above in any version of ACF, the test()
function returns an empty string. However, in Lucee it throws a key [MODIFIED] doesn't exist on line 3
exception.
Should I file a bug for this?dswitzer
03/16/2022, 1:58 PMdswitzer
03/16/2022, 1:59 PMwebsolete
03/16/2022, 2:18 PMvar local
is already problematic. if you return just local rather than local.modified, you get expected results. you're overwriting local with the code above and not sure what you think should be happening?dswitzer
03/16/2022, 2:23 PMlocal
as when CFML did not have a proper local
scope. Sometimes people did this so they didn't have to var
declare every variable and could just create variables as needed. So it wasn't uncommon to see code like in the above example.
I just happened to be working on migrating some older code that was using that syntax. It still works in ACF, which is why it was not noticed.websolete
03/16/2022, 2:25 PMwebsolete
03/16/2022, 2:26 PMwebsolete
03/16/2022, 2:27 PMbdw429s
03/16/2022, 3:35 PMvar local =
regardless of what's on the right hand sidebdw429s
03/16/2022, 3:35 PMvar local = {}
in CF 8bdw429s
03/16/2022, 3:36 PMzackster
03/16/2022, 3:51 PMAdam Cameron
But Lucee doesn't allow you to create a variable named after a scopeLucee doesn't seem to mind if I change
local
to session
in that example...?Adam Cameron
Adam Cameron
It's just so older code doesn't error where people used to doBut then they also might be doing precisely what Dan's example had. So it's not much of a bloody nod to that if it doesn't work CF's approach is a better "reverse shim" for the old-stylely "make your own pretend local scope" thing to still work, innit?
Adam Cameron
var local = {modified=""}
to do what the intent of the code is, then it should raise an exception, not just ignore it. Shurely?zackster
03/17/2022, 12:29 PM