tracker issue : CF-4202542

select a category, or use search below
(searches all categories and all time range)
Title:

[ANeff] Bug for: final ignored

| View in Tracker

Status/Resolution/Reason: Closed/Fixed/Fixed

Reporter/Name(from Bugbase): Aaron Neff / ()

Created: 05/21/2018

Components: Language

Versions: 13.0

Failure Type: Data Corruption

Found In Build/Fixed In Build: 2018.0.01.308605 (PreRelease) / 2018,0,0,309764

Priority/Frequency: Normal / All users will encounter

Locale/System: / Platforms All

Vote Count: 0

Issue: final ignored

Steps to Reproduce:
1) Run:
-----------
<cfscript>
  final variables.foo = "final honored"
  variables.foo = "final ignored"
  writeOutput(foo)//if `foo` is changed to `variables.foo`, then coldfusion.compiler.FinalVariableMutationException is thrown
</cfscript>
-----------

Actual Result: final ignored

Expected Result: coldfusion.compiler.FinalVariableMutationException on line 3

2) Run:
-----------
<cfscript>
  final variables.foo = "final honored"
  variables.foo = "final ignored"
  writeOutput(variables.foo)
  foo = "I call hacks"//if this line is commented-out, then coldfusion.compiler.FinalVariableMutationException is thrown
</cfscript>
-----------

Actual Result: final ignored

Expected Result: coldfusion.compiler.FinalVariableMutationException on line 3

3) Run:
-----------
<cfscript>
  final variables.foo = "final honored"
  foo = "final ignored"
  writeDump(foo)
</cfscript>
-----------

Actual Result: final ignored

Expected Result: coldfusion.compiler.FinalVariableMutationException on line 3

4) Run:
-----------
<cfscript>
  function f() {
    final local.foo = "final honored"
    var foo = "final ignored"
    return foo
  }
  writeDump(f())
</cfscript>
-----------

Actual Result: final ignored

Expected Result: coldfusion.compiler.FinalVariableMutationException on line 4

5) Run:
-----------
<cfscript>
  final variables.foo = "final honored"
  foo = function(){variables.bar="final ignored"}
  foo()
  writeOutput(isClosure(foo) & ' ' & bar)
</cfscript>
-----------

Actual Result: YES final ignored

Expected Result: coldfusion.compiler.FinalVariableMutationException on line 3

6) Run:
-----------
<cfscript>
  final variables.foo = "bar"
  function foo() {}//this line is completely ignored
  writeDump(foo)
</cfscript>
-----------

Actual Result: bar

Expected Result: coldfusion.compiler.FinalVariableMutationException on line 3

7) Run:
-----------
<cfscript>
  final cfthread="bar"
  cfthread(name="myThread"){}
  //thread name="myThread" {}//same issue
  thread action="join" name="myThread";
  writeDump(cfthread)
</cfscript>
-----------

Actual Result: bar

Expected Result: coldfusion.compiler.FinalVariableMutationException on line 3

8) Run:
mycustomtag.cfm
-----------
<cfscript>
  if(THISTAG.executionMode == "start") {
    final CALLER.foo = "final honored"
  }
</cfscript>
-----------
index.cfm
-----------
<cfscript>
  cfmodule(template="mycustomtag.cfm") 
  foo = "final ignored"
  writeOutput(foo)
</cfscript>
-----------

Actual Result: final ignored

Expected Result: coldfusion.compiler.FinalVariableMutationException on index.cfm line 3

Related post: http://blog.cfaether.com/2018/05/final-ignored.html

Attachments:

Comments:

All the cases have been fixed except the below two cases (explanation inline)-   6) Run: ----------- < cfscript> final variables.foo = "bar" function foo() {}//this line is completely ignored writeDump(foo) < /cfscript> ----------- Actual Result: bar Expected Result: coldfusion.compiler.FinalVariableMutationException on line 3 Analysis: This is not a valid case.  Run the below code and you will see UninvocableEntityException which means that CF doesn't allow you to have a variable and function with the same name. < cfscript> final variables.foo = "bar" function foo() {}//this line is completely ignored writeDump(foo()) < /cfscript>     |{color:#FFFFFF}The following information is meant for the website developer for debugging purposes.{color}| |{color:#FFFFFF}Error Occurred While Processing Request{color}| | |h1. Entity has incorrect type for being called as a function.| | 7) Run: ----------- < cfscript> final cfthread="bar" cfthread(name="myThread"){} //thread name="myThread" {}//same issue thread action="join" name="myThread"; writeDump(cfthread) < /cfscript>   The above case is invalid. Final works only on variable represented runtime entities, tags are not runtime variable entities.
Comment by Vijay M.
27909 | May 22, 2018 12:00:47 PM GMT
Hi Vijay, Thanks, yes, you are correct regarding #6. Regarding #7: By default tag cfhttp creates a variable named CFHTTP, tag cfthread creates a variable named CFTHREAD, tag cffile creates a variable named CFFILE, tag cflogin creates a variable named CFLOGIN, etc, etc, etc, etc. Can you just check the code base please, or CF's documentation? Any tag that, by default, creates a variable, needs to throw coldfusion.compiler.FinalVariableMutationException if that variable was previously made final. Also, this: <cfscript> final function foo() {} final variables.foo = "bar" writeDump(foo) </cfscript> Returns "bar" (bad) <cfscript> final function foo() {} final foo = "bar" writeDump(foo) </cfscript> Throws coldfusion.compiler.FinalVariableMutationException (good) That wasn't fixed as part of this ticket? This ticket needs re-opened. Final needs to work properly and not be ignored, which is the whole point of this ticket. Thanks!, -Aaron
Comment by Aaron N.
27942 | May 25, 2018 08:15:56 PM GMT
Hello? Question ^^
Comment by Aaron N.
28946 | May 29, 2018 06:03:01 PM GMT