Open nachoab opened 6 years ago
Another uglify error.
Here "bar" can be ignored because it is never used:
async function example() {
var foo, bar;
try {
[foo, bar] = await Promise.all([req(1), req(2)]);
} catch(e) {}
console.log(foo);
}
but the minifier ignores "foo" too:
async function example() {
var a;
try {
await Promise.all([req(1), req(2)])
} catch (a) {}
console.log(a)
}
If both "foo" and "bar" were used, the minifier does its job well:
async function example() {
var foo, bar;
try {
[foo, bar] = await Promise.all([req(1), req(2)]);
} catch(e) {}
console.log(foo, bar);
}
which is minified to:
async function example() {
var a, b;
try {
[a, b] = await Promise.all([req(1), req(2)])
} catch (a) {}
console.log(a, b)
}
Here goes another one:
Input:
function example(obj) {
if (!!obj.foo || obj.bar) {
return true;
}
return false;
}
Actual Result, which is not the same, it doesn't return a boolean:
function example(a){
return!!a.foo||a.bar
}
Expected Result, for instance:
function example(a){
return!!(!!a.foo||a.bar)
}
@nachoab the current pre-release of the CLI includes some updated Babel packages, that may or may not effect this. Could you try npm i -g polymer@next
and see if this still happens?
For your first example at least, it seems like the version of Babel minify that the Babel REPL uses isn't exhibiting the bug: https://babeljs.io/repl/#?babili=true&browsers=&build=&builtIns=false&code_lz=C4JwngBA3gUB8QPSIgZwPYFsCmwAWAlgHYDmcAvhAMYCGwVeAFNgJTRwJXpGrAQAmdbBAC8EItgDuEACJDGLANwd4XHugA22AHQb0JRoOCtl5IA&debug=false&forceAllTransforms=false&shippedProposals=false&circleciRepo=&evaluate=false&fileSize=false&lineWrap=false&presets=babili&prettier=false&targets=&version=6.26.0&envVersion=
The last one I think we'll need to file a Babel bug for: https://babeljs.io/repl/#?babili=true&browsers=&build=&builtIns=false&code_lz=GYVwdgxgLglg9mABAUwB4EMC2AHANsgCjgCMArASkQG8AoRRGYRAgQhZNIDpg45EAffog6di6AE6Va9euORQQ4pFHEhkAbjqIAvlrkKliYOlwBnDTW1A&debug=false&forceAllTransforms=false&shippedProposals=false&circleciRepo=&evaluate=false&fileSize=false&lineWrap=false&presets=babili&prettier=false&targets=&version=6.26.0&envVersion=
The last one is fixed too in the polymer@next version:
function example(a){return!(!a.foo&&!a.bar)}
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Description
This is an error of the js minifier. When the error variable is not used inside the catch statement, it is renaming it to "a", but if a variable is created inside the catch block it is also using "a". In case of const variables this throws an error because "a" has already been declared.
Versions & Environment
Steps to Reproduce
Minify this code:
Expected Results
Actual Results
If the error variable is used, then it is correctly minified.