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

ColdFusion Add 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?

2 responses to “"Default" key name in implicit struct in ColdFusion 9.0.1 causes syntax/compile error”

  1. David Boyer Says:
    I'm sure I recently hit an error when using st.function and had to us the alternative quoted string approach for the key name instead. I kind of understand function being reserved, but if there's a dot infront of it, can't CF tell the difference?
  2. Moving House Says:
    This is a good question David, but i am not sure that you will receive an answer...

Leave a Reply