tracker issue : CF-4198481

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

CF11 stopped accepting booleans as numeric args

| View in Tracker

Status/Resolution/Reason: Closed/Fixed/Fixed

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

Created: 04/04/2017

Components: Language, Functions

Versions: 2016,11.0

Failure Type: Incorrectly functioning

Found In Build/Fixed In Build: 11 / 2018,0,0,308513

Priority/Frequency: Normal /

Locale/System: / Platforms All

Vote Count: 2

Problem Description:
In CF10 and earlier a boolean value woudl be permissable as a value for a numeric argument to a function. As of CF11 this has changed

Steps to Reproduce:
http://trycf.com/gist/2554455579bb316e7da4d15de2d3f0c4/acf11?theme=monokai
(run it on CF10, CF11, CF2016 and Lucee to see the difference)


{code:java}
<cfscript>
function f(required numeric x){
    writeOutput(x.getClass().getName());
    writeOutput("<br>");
    writeOutput(x+1);
    writeOutput("<br>");
}

try {
    f(true);
} catch (any e){
    writeOutput("#e.message# #e.detail#");
    writeOutput("<br>");
}
writeOutput("<hr>");

f(now());

writeOutput("<hr>");

n = true + 1;
writeOutput(n);
writeOutput("<br>");
</cfscript>
{code}


Actual Result:
The X argument passed to the f function is not of type numeric. If the component name is specified as a type of this argument, it is possible that either a definition file for the component cannot be found or is not accessible.


Expected Result:
For it not to error. A boolean should be valid for a numeric arg

Any Workarounds:
Not relevant

There seems to be no ticket for why this change was made in the first place. It'd be helpful to understand why the change was made.

Attachments:

Comments:

+1 - This is a regression. Since boolean is treated as numeric in true+1, cfargument type numeric should still allow boolean.
Vote by Aaron N.
966 | April 04, 2017 07:36:37 PM GMT
Adobe can you pls feed back as to why this change was made in the first place?
Comment by Adam C.
965 | October 03, 2017 09:54:02 AM GMT