brandner
08/26/2022, 10:53 PMDaniel Mejia
08/26/2022, 10:56 PMbrandner
08/26/2022, 10:57 PMDaniel Mejia
08/26/2022, 10:57 PMbrandner
08/26/2022, 10:58 PMwebsolete
08/26/2022, 11:28 PMwebsolete
08/26/2022, 11:30 PMAdam Cameron
https://i2.paste.pics/e13262dc3092eec8fe49625f7b4d38a7.png▾
https://i2.paste.pics/611adc9f40476237329426995c8914f7.png▾
Adam Cameron
"123."
to be numeric, so seems to be coercing the testSubString
value into a numeric, so 123
and but it does not do the same to the literal "123."
so... what... ends up coercing the numeric back into a string ("123"
now) before comparing with "123."
, which are clearly not the same.
With ===
it leaves testSubString
as-is, so both strings are "123."
, and match.
---
Lucee doesn't consider "123."
to be numeric, so none of the back/forth coercion takes place for the EQ
and ==
operations. And it just messes up the ===
one. There's no way that should not be true
.Adam Cameron
eq
and `==`: they are the same), but added in another numeracy test, and checked a difference in how literals and variables are handled:
https://trycf.com/gist/c8e2d796c583de66c04cddd2472299a3/lucee5?theme=monokai
testString = "123.456.789.000";
testSubString = Left(testString,4);
compareTo = "123."
writeDump([
"testString" = testString,
"testSubString" = testSubString,
"isNumeric(testSubString)" = isNumeric(testSubString),
"testSubString * 1" = testSubString * 1,
'testSubString EQ "123."' = testSubString EQ "123.",
'testSubString == "123."' = testSubString == "123.",
'testSubString === "123."' = testSubString === "123.",
"compareTo" = compareTo,
"testSubString EQ compareTo" = testSubString EQ compareTo,
"testSubString == compareTo" = testSubString == compareTo,
"testSubString === compareTo" = testSubString === compareTo
])
https://i2.paste.pics/81f6ff10b08c388060dab88a57a4937e.png▾
https://i2.paste.pics/d6f06274b15da46d926f130c46cb8f2f.png▾
"123."
is not numeric, but then happily allows it to be used as one. It's gotta be one way or the other. Bug.
CF handles string literals differently to string variables (see the ==
test on both: different results). Bug.
And Lucee's bug with ===
.
I do so love CFML.Adam Cameron
Dave Merrill
08/27/2022, 11:59 AMAdam Cameron
Adam Cameron
isNumeric
behaviour on Lucee is new to me, I think.Adam Cameron
seancorfield
compare()
or compareNoCase()
for string comparisons in CFML?mtbrown
08/27/2022, 10:29 PMEQ
and NEQ
for string comparisons can be fraught. I always use compare
or compareNoCase
.brandner
08/29/2022, 2:48 PM