CHF Warning - Impacts MXUnit

This post is more than 2 years old.

Just a quick warning about the CHF I just blogged about. It makes a small change to the LOCAL scope that can impact your code. It definitely breaks MXUnit's test runner. The change involves code that sets LOCAL variable. Imagine the following UDF:

<cfscript> function foo() { var local = ""; local.x = 1; return x; } </cfscript>

<cfoutput>#foo()#</cfoutput>

Notice how I set local to a string, and then treat is a structure later. While that may be a bit sloppy, it works fine until you apply the CHF. Once you do, you get:

LOCAL is explicit scope in ColdFusion 9.
You can only assign LOCAL to a struct. You cannot assign LOCAL to java.lang.String

This is easy enough to fix, and easy to fix within MXUnit. Just find runner/HtmlRunner.cfc and delete line 13, which should be:

<cfset var local = "">

Raymond Camden's Picture

About Raymond Camden

Raymond is a senior developer evangelist for Adobe. He focuses on document services, JavaScript, and enterprise cat demos. If you like this article, please consider visiting my Amazon Wishlist or donating via PayPal to show your support. You can even buy me a coffee!

Lafayette, LA https://www.raymondcamden.com

Archived Comments

Comment 1 by Randy Merrill posted on 2/20/2010 at 9:55 PM

Thanks for letting us know Ray! It should be fixed in the trunk and will be part of the next release.

Comment 2 by Dan G. Switzer, II posted on 2/22/2010 at 8:48 PM

The better fix might be to change the line to <cfset var local = structNew() /> for backwards compatibility.

Comment 3 by Raymond Camden posted on 2/22/2010 at 8:49 PM

No, everyone uses CF9. ;)