<@U0BJDA84R> should "static" be added to the Reser...
# documentation
c
Might wanna ask Lucee the same question though šŸ˜‰
Oh, actually Lucee is OK when the code isn't running in trycf.
m
That page already says "Scope names" and I believe
static
is considered a scope. Although it seems to work fine for ColdFusion in Adam's example, but that could just be because it's not within a component which I believe is the only place where that scope would be applicable.
c
I guess the answer to the original question (should it be on the list) is "no".
a
When I run my examples outside of trycf (which is not really a very good tool for testing CFML language behaviour as it monkeys with the code before running it šŸ˜ž • both Lucee and CF fine with a variable called static in a .cfm file • CF have a compile error when doing same in a CFC • Lucee has a runtime error having ignored the variable assignment, and then erroring on the
writeOutput
Code:
Copy code
<!--- test.cfm --->
<cfscript>
static = "no reason for it to be a reserved word, no"
writeOutput(static)
</cfscript>
Copy code
// C.cfc
component {
    function f() {
        static = "no reason for it to be a reserved word, no" // Lucee just ignores this (bug) // CF won't compile this
        writeOutput(static) // and doesn't like this cos static is a complex object
    }
}

<!--- testC.cfm --->
<cfset o = new C()>
<cfset o.f()>
Ooh but CF's error detail is:
Reserved for static context.
hrm
m
I would expect that in ColdFusion. But does it work if you
var
scope it?
And regarding my scope comment above, it's actually not listed as a scope on https://helpx.adobe.com/coldfusion/developing-applications/the-cfml-programming-language/using-coldfusion-variables/about-scopes.html so 🤷
z
in lucee (most) scopes get converted/compiled in bytecode to direct references to the scope, so you can say session=zac, but session is still a scope https://docs.lucee.org/guides/developing-with-lucee-server/reserved-word.html
a
@mtbrown good thinking. If I change that line to
var static = "no reason for it to be a reserved word, no"
, then CF handles it fine. Lucee still ignores it. I worked out what Lucee is doing. In my method
static = "no reason for it to be a reserved word, no"
is being treated as an assignment of
local.static
(I have
modern
scope mode switched on on this instance). Fair cop. I would also expect a bare
static
reference (as per the following line) to be considered a reference to the static scope... other than that is not correct CFML behaviour as per the CF example. So even if Lucee is doing it on purpose, it's still a bug.
z
grab the generated class for your exmaple and run it thru a java decompiler