aboutsummaryrefslogtreecommitdiff
path: root/lib/compress.js
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2017-03-16 12:03:30 +0800
committerGitHub <noreply@github.com>2017-03-16 12:03:30 +0800
commita80b228d8be37eb6585bca01c6fb5468db5bea42 (patch)
treeaa6eafca577f69aaf4393ad767be2d3c69f95c18 /lib/compress.js
parentcf4bf4ceb1eee86197d51e77e640e59ca04739b8 (diff)
downloadtracifyjs-a80b228d8be37eb6585bca01c6fb5468db5bea42.tar.gz
tracifyjs-a80b228d8be37eb6585bca01c6fb5468db5bea42.zip
fix `hoist_vars` on `reduce_vars` (#1607)
`hoist_vars` converts variable declarations into plain assignments, which then confuses `reduce_vars` fixes #1606
Diffstat (limited to 'lib/compress.js')
-rw-r--r--lib/compress.js6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/compress.js b/lib/compress.js
index b3004fb5..49b618e7 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -1986,7 +1986,7 @@ merge(Compressor.prototype, {
vars.set(def.name.name, def);
++vars_found;
});
- var seq = node.to_assignments();
+ var seq = node.to_assignments(compressor);
var p = tt.parent();
if (p instanceof AST_ForIn && p.init === node) {
if (seq == null) {
@@ -2579,7 +2579,8 @@ merge(Compressor.prototype, {
this.definitions.forEach(function(def){ def.value = null });
});
- AST_Definitions.DEFMETHOD("to_assignments", function(){
+ AST_Definitions.DEFMETHOD("to_assignments", function(compressor){
+ var reduce_vars = compressor.option("reduce_vars");
var assignments = this.definitions.reduce(function(a, def){
if (def.value) {
var name = make_node(AST_SymbolRef, def.name, def.name);
@@ -2588,6 +2589,7 @@ merge(Compressor.prototype, {
left : name,
right : def.value
}));
+ if (reduce_vars) name.definition().fixed = false;
}
return a;
}, []);