Can't find a hint

I couldn’t find this on the Goggle, so: if your Coldfusion template occasionally furnishes you with the unhelpful, lineless error:

can’t load a null

then this might be caused by the following. You may be trying to compile a function using something like this code:

<cfset bar = “something”>
<cffunction name=”foo”>
    <cfargument name=”bar” default=”#bar#”>
</cffunction>

At the point of trying to interpret the cfargument, Coldfusion’s JRun core looks in the function’s ARGUMENTS scope for “bar” before checking the template scope; it finds it, because it’s just created the argument reference with that name; and tries to create a circular reference from ARGUMENTS.bar’s default to the value of (also ARGUMENTS.)bar . Hence total confusion, and an error without a line number (because the template is still being interpreted, not run).

Solution: rename the cfargument or the template variable.

Edit: David Sheldon has suggested that explicitly using the VARIABLES scope for the template-wide variable is as good a solution, although I should point out that you’re still likely to confuse yourself further on if you aren’t careful.

Exit gracefully: watch your scopes. Only use the template-wide scope if you absolutely know what your code will do with that variable.

Comments

This was just what I was looking for - thanks for giving Google something to return!

No problem. I hate Coldfusion scoping: I don't want to think what the underlying Java might be up to sometimes....