Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix collapse_vars regression in destructuring #2897

Merged
merged 1 commit into from
Feb 8, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/compress.js
Original file line number Diff line number Diff line change
Expand Up @@ -1512,6 +1512,7 @@ merge(Compressor.prototype, {
}

function may_modify(sym) {
if (!sym.definition) return true; // AST_Destructuring
var def = sym.definition();
if (def.orig.length == 1 && def.orig[0] instanceof AST_SymbolDefun) return false;
if (def.scope.get_defun_scope() !== scope) return true;
Expand Down
33 changes: 33 additions & 0 deletions test/compress/destructuring.js
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,39 @@ mangle_destructuring_decl: {
node_version: ">=6"
}

mangle_destructuring_decl_collapse_vars: {
options = {
collapse_vars: true,
evaluate: true,
unused: true,
}
mangle = {
}
input: {
function test(opts) {
let a = opts.a || { e: 7, n: 8 };
let { t, e, n, s = 5 + 4, o, r } = a;
console.log(t, e, n, s, o, r);
}
test({a: { t: 1, e: 2, n: 3, s: 4, o: 5, r: 6 }});
test({});
}
expect: {
function test(t) {
let e = t.a || { e: 7, n: 8 };
let {t: n, e: o, n: s, s: l = 9, o: a, r: c} = e;
console.log(n, o, s, l, a, c);
}
test({ a: { t: 1, e: 2, n: 3, s: 4, o: 5, r: 6 } });
test({});
}
expect_stdout: [
"1 2 3 4 5 6",
"undefined 7 8 9 undefined undefined",
]
node_version: ">=6"
}

mangle_destructuring_assign_toplevel_true: {
options = {
toplevel: true,
Expand Down
2 changes: 1 addition & 1 deletion test/run-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ function run_compress_tests() {
});
return false;
}
if (0 && test.reminify && !reminify(test.options, input_code, input_formatted, test.expect_stdout)) {
if (test.reminify && !reminify(test.options, input_code, input_formatted, test.expect_stdout)) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please leave this out - I don't want to redo this for every harmony merge.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why release uglify-es at all then if every new uglify-js feature renders it unusable?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm performing this merge on a best-effort basis, in the belief that it would be usable for the majority of use cases out there.

If this is not the case and requires more effort on my part, I would indeed stop making any future uglify-es releases.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your work on uglify-es. I appreciate you'd rather concentrate on uglify-js.

A reminify test failure is no different than a regular test failure. Disabling it would just mask future regressions. It would be best not to release uglify-es with known regressions and just let harmony diverge from master.

Copy link
Collaborator

@alexlamsl alexlamsl Feb 8, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay - in that case this is the last PR I would accept for harmony and it shall be frozen from now on.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alexlamsl any chance we get a quick bugfix release for uglify-es though? This regression hit many of our projects using uglifyjs-webpack-plugin.

return false;
}
}
Expand Down