diff --git a/lib/compress.js b/lib/compress.js index 0d4370b9..239bd48e 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -6245,8 +6245,10 @@ Compressor.prototype.compress = function(node) { || !mergeable(head_refs, tail_refs) || (head_refs.start.loop || !same_scope(def)) && !mergeable(tail_refs, head_refs) || compressor.option("webkit") && is_funarg(def) !== is_funarg(head.definition) - || !safe_to_rename(head_refs, def) - || !safe_to_rename(references[def.id], head.definition)) { + || head.definition.const_redefs + || !all(head_refs, function(sym) { + return sym.scope.find_variable(def.name) === def; + })) { skipped.push(head); continue; } @@ -6348,12 +6350,6 @@ Compressor.prototype.compress = function(node) { function mergeable(head, tail) { return must_visit(head.start, head.end) || must_visit(head.start, tail.start); } - - function safe_to_rename(refs, def) { - return all(refs, function(sym) { - return sym.scope.find_variable(def.name) === def; - }); - } }); function fill_holes(orig, elements) { diff --git a/test/compress/let.js b/test/compress/let.js index 6e9cdb63..dba0b6ac 100644 --- a/test/compress/let.js +++ b/test/compress/let.js @@ -270,8 +270,8 @@ merge_vars_3: { var b = console; console.log(typeof b); } - var a = 1; - console.log(typeof a); + var b = 1; + console.log(typeof b); } expect_stdout: [ "object",