tracker issue : CF-3972082

select a category, or use search below
(searches all categories and all time range)
Title:

param doesn't work

| View in Tracker

Status/Resolution/Reason: Closed/Withdrawn/AsDesigned

Reporter/Name(from Bugbase): Adam Cameron / Adam Cameron (Adam Cameron)

Created: 04/18/2015

Components: Language

Versions: 11.0

Failure Type:

Found In Build/Fixed In Build: CF11_Final /

Priority/Frequency: Major / Some users will encounter

Locale/System: English / Platforms All

Vote Count: 0

Repro:

<cfscript>
param url.test = defaulter();

writeOutput("test: #url.test#");

function defaulter(){
	writeOutput("defaulter() ran<br>");
	return "default";
}
</cfscript>

Whether or not you pass a value for url.test, defaulter() is *always* run. It should only run if URL.test is not set.

----------------------------- Additional Watson Details -----------------------------

Watson Bug ID:	3972082

External Customer Info:
External Company:  
External Customer Name: Adam
External Customer Email:  
External Test Config: My Hardware and Environment details:

Attachments:

Comments:

For any tag, the expression used in an attribute value is evaluated before processing the tag and therefore the function would always get called. script syntax works exactly the same way.
Comment by Awdhesh K.
7775 | August 18, 2015 07:17:22 AM GMT
Yeah, I know how it works mate. My point was rather more than it *shouldn't* work like that. Bear in mind CFML ain't executed; you lot compile it first. So the param statement *could* be compiled to {code} if the variable doesn't exist then run the default code and assign it to the variable endif {code} I know with the tag your hands are likely tied because there's likely to be a generic tag handler than processes all the attributes first, but this doesn't need to be the case with script constructs. And there's no need to perpetuate a shortfall in the general tag implementation in script constructs, especially if it defeats the intent of the construct. If you can short-circuit if / ?: etc, you can short-circuit param.
Comment by External U.
7776 | August 18, 2015 07:25:10 AM GMT