enhance varify (#5658)
This commit is contained in:
@@ -10120,9 +10120,11 @@ Compressor.prototype.compress = function(node) {
|
||||
}
|
||||
|
||||
function can_varify(compressor, sym) {
|
||||
if (!sym.fixed_value()) return false;
|
||||
var def = sym.definition();
|
||||
return is_safe_lexical(def) && same_scope(def) && !may_overlap(compressor, def);
|
||||
return (def.fixed || def.fixed === 0)
|
||||
&& is_safe_lexical(def)
|
||||
&& same_scope(def)
|
||||
&& !may_overlap(compressor, def);
|
||||
}
|
||||
|
||||
function varify(self, compressor) {
|
||||
|
||||
@@ -194,6 +194,43 @@ scope_adjustment_let: {
|
||||
node_version: ">=4"
|
||||
}
|
||||
|
||||
escaped_const: {
|
||||
options = {
|
||||
reduce_vars: true,
|
||||
toplevel: true,
|
||||
varify: true,
|
||||
}
|
||||
input: {
|
||||
const log = console.log;
|
||||
log("PASS");
|
||||
}
|
||||
expect: {
|
||||
var log = console.log;
|
||||
log("PASS");
|
||||
}
|
||||
expect_stdout: "PASS"
|
||||
}
|
||||
|
||||
escaped_let: {
|
||||
options = {
|
||||
reduce_vars: true,
|
||||
toplevel: true,
|
||||
varify: true,
|
||||
}
|
||||
input: {
|
||||
"use strict";
|
||||
let log = console.log;
|
||||
log("PASS");
|
||||
}
|
||||
expect: {
|
||||
"use strict";
|
||||
var log = console.log;
|
||||
log("PASS");
|
||||
}
|
||||
expect_stdout: "PASS"
|
||||
node_version: ">=4"
|
||||
}
|
||||
|
||||
issue_4191_const: {
|
||||
options = {
|
||||
functions: true,
|
||||
|
||||
Reference in New Issue
Block a user