CFFUNCTION arguments are always defined?

this is legacy from railo all lucee versions probably.
on ACF gives exception
argument ss is undefined

but not on lucee. why ?


<cffunction name="aa" output="true">
  	<cfargument name="ss">     <!---- if I don't declare - exception is raised ---->
	<cfoutput>defined? #isdefined('arguments.ss')#.</cfoutput>	  
	<cfset ss = arguments.ss & 'but im ok'> 		
	<cfoutput>#ss#</cfoutput>	
</cffunction>  

  <cfset aa()>

It’s there, but null. With null support off, that makes it “undefined” by cfml standards. However, you can concatenate a string with null and the null just turns into an empty string.

I think ACF just literally doesn’t define it, even as null.

Looks like ACF populates the arguments scope with the key ss and lets the value undefined, while Lucee seems to assign the value to null to that key, that is casted to an empty string on ouput.

See this gist and try changinging the cfenfine.

See also that (old but) interresting and related blog post from @bennadel ColdFusion ARGUMENTS Keys Always Exist, Even When Not Required

thank you

1 Like