Incorrect minification
Closed this issue · 2 comments
Code with a + operator followed by a pre-increment operator is minified incorrectly, generating syntax errors.
The bug is triggered by a similar construction in underscore.js
jsmin.jsmin('function foo() { return "" + ++idCounter; }')
'function foo(){return""+++idCounter;}'
Since this is based on the original implementation of jsmin by Mr Crockford, of course such issue exist. Check out here at the caution section:
Use parens with confusing sequences of + or -. For example, minification changes
a + ++b
into
a+++b
which is interpreted as
a++ + b
which is wrong. You can avoid this by using parens:
a + (++b)
JSLint checks for all of these problems. It is suggested that JSLint be used before using JSMin.
Ran into the same issue. I would prefer not to have to be cautious.