CHF Warning - Impacts MXUnit

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> </code>

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 developer advocate. He focuses on JavaScript, serverless and enterprise cat demos. If you like this article, please consider visiting my Amazon Wishlist or donating via PayPal to show your support.

Lafayette, LA