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
Ben Nadel's Company - Epicenter Consulting Recent Blog Comments
May 22, 2013 at 7:52 AM
Nested Views, Routing, And Deep Linking With AngularJS
Hi, Just a quick thank you. As it happens, for my own purposes, the pending ui-router work being done in native angular is likely the one I'll adopt, but your exploration, code and documentation of ... read »
May 22, 2013 at 4:43 AM
How Do You Use The ColdFusion CFParam Tag?
'<cfparam>' or 'isDefined()and <cfset>' performs the same task.Is there any difference? ... read »
May 21, 2013 at 7:46 PM
Using Plupload For Drag & Drop File Uploads In ColdFusion
No luck. At least I have uncovered the cause, URLScan 3.1. Here is what I see in the IIS log when a file is over 30mb. 2013-05-21 23:29:05 10.105.45.128 GET /plupload/assets/jquery/jquery-1.8. ... read »
May 21, 2013 at 6:12 PM
Using Plupload For Drag & Drop File Uploads In ColdFusion
Ben, I did not see you after Pete Freitag's Lockdown session at cfObjective but he said that IIS sets file size limits at 30MB by default which just happened to be the threshold for file size when ... read »
May 21, 2013 at 11:51 AM
Ask Ben: Parsing Very Large XML Documents In ColdFusion
Looking at my first ever XML document that I have to parse and put into MS SQL 2000 with CF8. I get it to list the desired Field name, many times over, and have a long list of this field name displa ... read »
May 21, 2013 at 9:25 AM
Turning Off and On Identity Column in SQL Server
you are awesome..i am lucky to get this blog between such a garbage one....Thanks, Prashant ... read »
May 20, 2013 at 4:38 PM
Using A Dynamic Column Name With ValueList() In ColdFusion
@Dana, Your confusion is well founded, since this is a very confusing features. In fact, it ONLY works if you use array notation. Meaning, that this: arrayToList( query[ "columnName" ] ) ... read »
May 20, 2013 at 4:34 PM
Using A Dynamic Column Name With ValueList() In ColdFusion
I was thinking chicken and the egg, I wouldn't have expected it to work in the valuelist going in I guess. Maybe I just need a beer, long day :) ... read »
InVision App - Prototyping Made Beautiful With Prototyping Tools