Arguments with type of "numeric" are not being cast to double

Description

Functions that have arguments specified as "numeric" do not treat the values as numeric.

For example, take the following function:

Now if you run the following, the results may not be as expected:

In ACF, both would return true, and that's what I'd expect to happen here.

The problem is that arguments.input ends up equaling 0.08263888888888889 when the original input is a string, but when run through abs() it ends up being cast to a double and becomes 0.082638888889 so when the values are compared, they are not equal.

Here is a gist that shows off the issue:
https://www.trycf.com/gist/14bea07bc4311e74b5c06cc93b1280ad/lucee5?theme=monokai

It would seem like values being passed into a function with a data type of numeric should be cast to a double so that all math operations match. However, that could have some real ramifications.

Alternatively, perhaps the comparison functions just need to be fixed so that when comparing a value that's a "string" to a native number type, that the string is cast to the same number type (i.e. cast to a double) so that the strings would be compared equally.

Environment

Tomcat 9/CentOS 7/Apache 2.4

Activity

Show:
Pothys - MitrahSoft
September 11, 2020, 7:45 AM

I've checked this ticket and confirmed the issue happened on lucee. Works fine with ACF. I added a test case for this issue.

Pull request: https://github.com/lucee/Lucee/pull/1029

Assignee

Michael Offner

Reporter

Dan Switzer, II

Priority

Major

Fix versions

None

Affects versions

Configure