In expressions such as "text" + (1 + 2), parentheses are lost.
kindaro opened this issue · comments
Ignat Insarov commented
Hello.
Let me commence with an example.
% cat > example.js
console.log ( "text" + (1+2) );
% node example.js
text3
% js2coffee example.js > example.coffee
% coffee example.coffee
text12
What happens here is:
- In JS case, the numeric sum in parentheses is calculated, then casted to string.
- In CoffeeScript case, the numbers are casted to strings one by one.
I believe the (+) operator is generally not associative in JavaScript because of the possibility of implicit casts. So maybe we should preserve parentheses.