Entries for month: March 2012

"Default" key name in implicit struct in ColdFusion 9.0.1 causes syntax/compile error

ColdFusion 2 Comments »

I was messing around with implicit structs in ColdFusion 9.0.1 when I came across something odd.  When I tried to code an implicit struct that contained a struct key named "default", like so:

myStruct= {default="foo"};

...ColdFusion Builder would give me the code coloring equivalent of the stink eye (usually indicative of a syntax error somewhere), and if I tried to run the code, I would get an "Invalid CMFL construct" error.

Coding the same struct in tag format:

<cfset myStruct.default= "foo" />

...works just fine. I then tried out enclosing the key name in double-quotes as well:

myStruct= {"default"="foo"};

...and ColdFusion will accept that.

Now of course "default" is a particular and significant attribute in certain contexts like cfparam and cfargument, but that shouldn't be an issue here.  I found nothing in the bug database or on Google about this quirk, so perhaps there's a reason for it that I either don't know or can't remember?