This feels like a Lucee compatibility bug to me: ...
# lucee
d
This feels like a Lucee compatibility bug to me: https://www.trycf.com/gist/f40c924b1651fd4ecb22d8837e48c568/acf2016?theme=monokai
Copy code
<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?
I did look for an existing bug in the backlog, but did not find one.
w
not sure what you're trying to demonstrate, but
var 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?
👍 1
d
This is some legacy code I ran into. It used to be very common developer practice to use the variable
local
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.
w
i recall that and see plenty of legacy code myself using the technique, but it became unnecessary in cf9 or 10 and i seem to recall it being really bad in railo/lucee v4.x as it obliterated the local scope when you did it
and it shouldn't have been allowed to work in acf, certainly not to this point.
i didn't look at the ticket you linked to, but it doesn't sound very bug-like to me, sounds like lucee does what you'd expect and acf's allowance for this is wrong. just my two cents
b
Yeah, Lucee basically ignores any declaration of
var local =
regardless of what's on the right hand side
It's just so older code doesn't error where people used to do
Copy code
var local = {}
in CF 8
But Lucee doesn't allow you to create a variable named after a scope
z
yep, you can write it, but lucee will always bypass it and return the local scope
a
But Lucee doesn't allow you to create a variable named after a scope
Lucee doesn't seem to mind if I change
local
to
session
in that example...?
(or any of the other few scope names I tried)
It's just so older code doesn't error where people used to do
But 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?
Also, if Lucee doesn't support
var local = {modified=""}
to do what the intent of the code is, then it should raise an exception, not just ignore it. Shurely?
z
runtime variable name checking overhead for all CF scopes names? bit of a performance overhead for a rare edge case