babel / minify

:scissors: An ES6+ aware minifier based on the Babel toolchain (beta)
https://babeljs.io/repl
MIT License
4.39k stars 225 forks source link

broken minified code: v + "" == "x"; #886

Open jfgodoy opened 6 years ago

jfgodoy commented 6 years ago

Describe the bug There is a bug in the minification of the following code.

To Reproduce babel try it out

input

function compare(v) {
  return v + "" == "x";
}
compare(4) // false
compare('a') // false

Actual Output

function compare(a) {
  return a + "x";
}
compare(4) // '4x'
compare('a') // 'ax'

Expected Output don't minify this case

zhangshichun commented 5 years ago

yes!!!i have a same problem too!! how did u fix it ?