ColdFusion 10 Beta - Miscellaneous Parsing Bugs And Oddities

Posted February 24, 2012 at 8:58 AM by Ben Nadel

Tags: ColdFusion

As I've been poking around in the ColdFusion 10 beta, I've come across a few parsing bugs and oddities. I blogged before about a critical bug with function expressions; and, I'm happy to report that the bug has already been fixed internally for the next ColdFusion 10 build. The following are some more parsing bugs and oddities that I have found.

Return Statements And Implicit Notation

While the return() statement is not a "function" call, I tend to use the "()" notation when executing it. I just like the way it looks and I believe it does a better job of delimiting the code. Unfortunately, it looks like you cannot use the parenthesis if you are returning a value that is defined using implicit notation. That is, you cannot use "return()" in conjunction with implicit arrays, implicit structs, or function expressions. None of the following return statements parse:

  • <cfscript>
  •  
  •  
  • // None of the following three return() statements work when used
  • // in conjunction with implicit-notations for ARRAY, STRUCT, and
  • // CLOSURE. Must return "( )" from return statement in order to
  • // parse properly.
  • function returnImplictNotation(){
  •  
  • return( [ ] );
  • return( { } );
  • return( function(){ } ) ;
  •  
  • }
  •  
  •  
  • </cfscript>

All of these return() statements throw a parsing error. If you simply remove the "()" portion of the return statement, however, they run properly.

Function Expressions In Implicit Structs And Arrays

You can assign function expressions to variables; you can assign function expression to properties; you can put function expression in arrays; you cannot, however, define function expressions as part of an implicit struct or an implicit array notation. None of the following implicit construct statements parse:

  • <cfscript>
  •  
  •  
  • // Function expressions / closures cannot be defined in the
  • // context of an implict struct.
  • udfs = {
  • doThis: function(){ },
  • doThat: function(){ },
  • };
  •  
  •  
  • // Function expressions / closures cannot be defined in the
  • // context of an implict array.
  • callbacks = [
  • function(){ },
  • function(){ }
  • ];
  •  
  •  
  • </cfscript>

All of these implicit notation statements throw a parsing error.

Invoking Methods Using Thread Attributes Scope

This is a really strange error. It's not a parsing error - it's some sort of context evaluation error. If you pass values into a CFThread tag using the tag attributes, you can access those values from within the CFThread tag body using the "Attributes" scope. However, if the value is a function or a function expression, the function cannot be invoked off of the "attributes" scope.

  • <cfscript>
  •  
  •  
  • // Define our UDF to pass into the thread.
  • doSomething = function(){
  • // ...
  • };
  •  
  •  
  • // Spawn a thread and pass-in the UDF as an attribute.
  • thread
  • name = "testFunctionCall"
  • action = "run"
  • udf = doSomething
  • control = "Simple Value"
  • {
  •  
  • // As a "control", export the simple value.
  • thread.control = attributes.control;
  •  
  • // Invoke off of attributes -- for some reason, this throws
  • // an error (regardless of whether or not the given function
  • // is a standard function or a closure). It can be invoked
  • // without scoping... but NOT with it.
  • attributes.udf();
  •  
  • }
  •  
  •  
  • // Join the thread so we can see the output.
  • thread action = "join";
  •  
  • // Outpu the thread properties.
  • writeDump( cfthread );
  •  
  •  
  • </cfscript>

As you can see, we're passing in a control [simple] value and a closure into this CFThread tag. We are then executing attributes-scoped access on each value. When we run the above code, the "attributes.control" statement works; but, the "attributes.udf()" throws the following error:

Either there are no methods with the specified method name and argument types or the udf method is overloaded with argument types that ColdFusion cannot decipher reliably. ColdFusion found 0 methods that match the provided arguments. If this is a Java object and you verified that the method exists, use the javacast function to reduce ambiguity.

If you remove the "attributes." scope from the udf() invocation, it works perfectly.

So far, I'm really loving the ColdFusion 10 features. There's just a few parsing bugs that need to be ironed out before the next public release.


You Might Also Be Interested In:



Reader Comments

Feb 24, 2012 at 8:09 PM // reply »
1 Comments

This doesn't work either, but does work in Railo 4:

myFunction(
function() {
return '';
},
function() {
return '';
}
)


Post A Comment

Comment Etiquette: Please do not post spam. Please keep the comments on-topic. Please do not post unrelated questions or large chunks of code. And, above all, please be nice to each other - we're trying to have a good conversation here.

Please review the following issues:

Author Name:


Author Email:

Author Website:

Comment:

Supported HTML tags for formatting: <strong>bold</strong>   <em>italic</em>   <code>code</code>







  • Help Wanted - Find Your Next ColdFusion Job
InVision App - Prototyping Made Beautiful With Prototyping Tools Ben Nadel's Company - Epicenter Consulting Recent Blog Comments
May 21, 2012 at 1:58 AM
Updated: Converting A ColdFusion Query To CSV Using QueryToCSV()
Hi Ben, why do you need to have so many double quotes when adding the field and field name to the row data? ----------------------------------------- <cfset LOCAL.RowData[ LOCAL.ColumnIndex ] = ... read »
AXL
May 21, 2012 at 1:24 AM
URL Rewriting And ColdFusion's WriteToBrowser Image Functionality (CFFileServlet)
@Mounir, Open your lower case URL Rewrite rule and add the following condition. Condition input: {REQUEST_URI} Check if input string: Does Not Match the Pattern Pattern: ^/CFFileServlet/_cf_ca ... read »
May 20, 2012 at 4:28 AM
Understanding The Complex And Circular Relationships Between Objects In JavaScript
@Will Vaughn I tried your javascript example but got this error:- foo.print is not a function ... read »
May 19, 2012 at 5:37 AM
A Graphical Explanation Of Javascript Closures In A jQuery Context
Thanks for this article, but I fear you missed an important point. If variables in the outer context change, these changes affect the inner anonymous functions as well. That means: if you change the ... read »
May 18, 2012 at 3:39 PM
Parsing CSV Data With An Input Stream And A Finite State Machine
Can you use file upload button with this? and read live? or does the file have to already be on the server saved? ... read »
May 18, 2012 at 1:06 AM
VIRGO (Aug. 23-Sept. 22): Dead On The Money!
A friend of mine and I were arguing about astrology and she told me that he believes in astrology. She hasn't provided me with any evidence that the belief makes any sense to me. She she been telling ... read »
May 17, 2012 at 11:32 PM
Using ColdFusion to Handle 404 Errors (Page Not Found) On Development Server
Very easy the configuration. I read a lot pages and I can't find the solution. I open the administrator and change this Administrator/server settings/Error Handlers/Missing Template Handler and p ... read »
May 17, 2012 at 3:13 PM
LOCAL Variables Scope Conflicts With ColdFusion Query of Queries
I never cease to be amazed that almost EVERY random CF issue I come across lands me on your site. Thank you for documenting your findings for the world. ... read »