[Pkg-javascript-commits] [uglifyjs] 453/491: fix accounting after conversion to assignment (#2847)
Jonas Smedegaard
dr at jones.dk
Wed Feb 14 19:52:03 UTC 2018
This is an automated email from the git hooks/post-receive script.
js pushed a commit to annotated tag debian/3.3.10-1
in repository uglifyjs.
commit 193612ac67ef269d6b05fdf61c9638a5eebd76f7
Author: Alex Lam S.L <alexlamsl at gmail.com>
Date: Fri Jan 26 14:21:11 2018 +0800
fix accounting after conversion to assignment (#2847)
Missing reference to `AST_SymbolRef` created by `unused` causes `collapse_vars` to misbehave.
fixes #2846
---
lib/compress.js | 4 +++-
test/compress/drop-unused.js | 27 +++++++++++++++++++++++++++
2 files changed, 30 insertions(+), 1 deletion(-)
diff --git a/lib/compress.js b/lib/compress.js
index 33b4313..07128af 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -3038,9 +3038,11 @@ merge(Compressor.prototype, {
if (var_defs.length > 1 && (!def.value || sym.orig.indexOf(def.name) > sym.eliminated)) {
compressor.warn("Dropping duplicated definition of variable {name} [{file}:{line},{col}]", template(def.name));
if (def.value) {
+ var ref = make_node(AST_SymbolRef, def.name, def.name);
+ sym.references.push(ref);
var assign = make_node(AST_Assign, def, {
operator: "=",
- left: make_node(AST_SymbolRef, def.name, def.name),
+ left: ref,
right: def.value
});
if (fixed_ids[sym.id] === def) {
diff --git a/test/compress/drop-unused.js b/test/compress/drop-unused.js
index 0ac7bb3..e99d7ab 100644
--- a/test/compress/drop-unused.js
+++ b/test/compress/drop-unused.js
@@ -1692,3 +1692,30 @@ issue_2768: {
}
expect_stdout: "PASS undefined"
}
+
+issue_2846: {
+ options = {
+ collapse_vars: true,
+ reduce_vars: true,
+ toplevel: true,
+ unused: true,
+ }
+ input: {
+ function f(a, b) {
+ var a = 0;
+ b && b(a);
+ return a++;
+ }
+ var c = f();
+ console.log(c);
+ }
+ expect: {
+ var c = function(a, b) {
+ a = 0;
+ b && b(a);
+ return a++;
+ }();
+ console.log(c);
+ }
+ expect_stdout: "0"
+}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/uglifyjs.git
More information about the Pkg-javascript-commits
mailing list