David Harris's Technology Blog

ColdFusion, Flex, and other stuff...   (and 338,402 hours, 5 mins in to my plan for global domination)

Search:

Calendar:

Sun Mon Tue Wed Thu Fri Sat
  1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31      

Subscribe:

Enter your email address to subscribe to this blog.

Archives By Subject:

Tags:

action script adobe air ajax cfug coldfusion flash flex frameworks free software fxug general jpgmetadatareader mac off topic opensource papervision spry

Recent Entries:

No recent entries.

Top Posts:

Recent Comments:

Top Commenters:

My Links:

RSS:


ColdFusion Error: can't load a null

I was working with a CFC today and ColdFusion threw this error at me:

can't load a null

There was no more information than that...

I'm not sure why is this error happens, but I did work what is causing it...

If you define a function that has an argument that has a default that is a variable or function with the same name as any of the arguments, this error is thrown.

You don't even need to call the function, you just need to define it.

Create a .cfm or .cfc and put this function in it:

<cffunction name="someFunction">

   <cfargument name="myValue" default="#myValue#">

   <cfreturn false>

</cffunction>

The error is occurring when ColdFusion is parsing the code, and not running it.

Weird eh?

I'm off to http://www.adobe.com/go/wish now to log a bug (all-be-it an obscure odd one...)

Comments
If I had to make an educated guess I'd say this happens because when the CF parser/compiler is looking for the refrence to the variable named "myValue" in an internal symbol table and can't find it. I would make a bet if you had two arguments, the second defaulting to the value of the first it would work fine:
<cffunction name="foo">
<cfargument name="firstArg" default="1">
<cfargument name="secondArg" default="#firstArg#">
</cffunction>
# Posted By Robert Gatti | 4/12/08 2:09 AM
Did you scope the variable in the original function call? It probably has something to do with the function trying to figure out scope and not knowing quite how to handle a variable with exactly the same name as one of its arguments.
# Posted By Gareth | 4/12/08 2:16 AM
I think it would be nice if Adobe would publish list of all internal errors thorwn by CF so we could at least locate tag/function/situation which is causing it.
# Posted By radek | 4/12/08 4:51 AM
Hi guys, thanks for the comments.

@Robert: I tested exactly that, and you are correct in that it won't throw an error. Good spotting

@Gareth: The error is thrown at parsing time and not run-time. The code just has to be there and not even run for the issue to happen :-) - try it out, you'll see what I mean

@Radek: I'm not sure what you mean by that. I suspect Adobe didn't know about this issue, so they couldn't of told us about it even if they wanted to.
Or are you meaning that the error reporting tells us more information? (EG: like every other "normal" error will tell us with "Enable Robust Exception Information" turned on)
# Posted By David | 4/12/08 11:03 AM