In expressions such as "text" + (1 + 2), parentheses are lost. #444

kindaro opened this Issue Jul 26, 2016 · 0 comments


None yet

1 participant

kindaro commented Jul 26, 2016


Let me commence with an example.

% cat > example.js
console.log ( "text" + (1+2) );
% node example.js
% js2coffee example.js >
% coffee

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment