Bug: Addition operator does not properly handle implicit conversions
Both of those code blocks should yield the same result (6). However the first does not. In the first rule, the expected implicit conversion to a numeric does not occur and it results in 60
The Set (Temp) in the second rule converts the string “6” to a numeric (or the variable is subsequently treated as a numeric) so the second rules results in the expected result of 6
Further testing with other operators yields these results
String “6” + 0 // 60 (wrong)
String “6” - 0 // 6 (correct)
String “6” * 1 // 6 (correct)
String “6” / 1 // 6 (correct)
Note: It could be argued that the existing implementation is appropriate so that users can concatenate numerics into a single string. But that’s a bad argument IMO as
- the 2 rules shown would be expected to yield the same result,
- implicit conservations should be consistent, and
- concatenation of numerics can be done with by simple math, e.g., (6*10)+0 = 60 or by forcing a string “ “+6+0 = “ 60” (and the first character can easily be removed if desired)