@@ -5906,10 +5906,7 @@ merge(Compressor.prototype, {
|
|||||||
this.write_only = !exp.has_side_effects(compressor);
|
this.write_only = !exp.has_side_effects(compressor);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
if (this.operator == "typeof" && exp instanceof AST_SymbolRef) {
|
if (this.operator == "typeof" && exp instanceof AST_SymbolRef && drop_symbol(exp)) return null;
|
||||||
if (drop_symbol(exp)) return null;
|
|
||||||
if (exp.is_declared(compressor)) return exp;
|
|
||||||
}
|
|
||||||
var node = exp.drop_side_effect_free(compressor, first_in_statement);
|
var node = exp.drop_side_effect_free(compressor, first_in_statement);
|
||||||
if (first_in_statement && node && is_iife_call(node)) {
|
if (first_in_statement && node && is_iife_call(node)) {
|
||||||
if (node === exp && this.operator == "!") return this;
|
if (node === exp && this.operator == "!") return this;
|
||||||
|
|||||||
@@ -277,6 +277,9 @@ AST_Toplevel.DEFMETHOD("figure_out_scope", function(options) {
|
|||||||
function redefine(node, scope) {
|
function redefine(node, scope) {
|
||||||
var name = node.name;
|
var name = node.name;
|
||||||
var old_def = node.thedef;
|
var old_def = node.thedef;
|
||||||
|
if (!all(old_def.orig, function(sym) {
|
||||||
|
return !(sym instanceof AST_SymbolConst || sym instanceof AST_SymbolLet);
|
||||||
|
})) return;
|
||||||
var new_def = scope.find_variable(name);
|
var new_def = scope.find_variable(name);
|
||||||
if (new_def) {
|
if (new_def) {
|
||||||
var redef = new_def.redefined();
|
var redef = new_def.redefined();
|
||||||
@@ -294,7 +297,6 @@ AST_Toplevel.DEFMETHOD("figure_out_scope", function(options) {
|
|||||||
node.redef = true;
|
node.redef = true;
|
||||||
node.thedef = new_def;
|
node.thedef = new_def;
|
||||||
node.reference(options);
|
node.reference(options);
|
||||||
if (node instanceof AST_SymbolConst || node instanceof AST_SymbolLet) new_def.orig.push(node);
|
|
||||||
});
|
});
|
||||||
if (old_def.lambda) new_def.lambda = true;
|
if (old_def.lambda) new_def.lambda = true;
|
||||||
if (new_def.undeclared) self.variables.set(name, new_def);
|
if (new_def.undeclared) self.variables.set(name, new_def);
|
||||||
|
|||||||
@@ -438,7 +438,7 @@ catch_ie8_1: {
|
|||||||
}
|
}
|
||||||
expect: {
|
expect: {
|
||||||
try {} catch (a) {}
|
try {} catch (a) {}
|
||||||
console.log(function a() {
|
console.log(function() {
|
||||||
}());
|
}());
|
||||||
}
|
}
|
||||||
expect_stdout: "undefined"
|
expect_stdout: "undefined"
|
||||||
@@ -1065,3 +1065,22 @@ issue_4229: {
|
|||||||
}
|
}
|
||||||
expect_stdout: true
|
expect_stdout: true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
issue_4231: {
|
||||||
|
options = {
|
||||||
|
ie8: true,
|
||||||
|
side_effects: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
typeof a == 0;
|
||||||
|
console.log(typeof function a() {
|
||||||
|
const a = 0;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
console.log(typeof function a() {
|
||||||
|
const a = 0;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
expect_stdout: "function"
|
||||||
|
}
|
||||||
|
|||||||
@@ -871,3 +871,25 @@ issue_4229: {
|
|||||||
expect_stdout: "PASS"
|
expect_stdout: "PASS"
|
||||||
node_version: ">=4"
|
node_version: ">=4"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
issue_4231: {
|
||||||
|
options = {
|
||||||
|
ie8: true,
|
||||||
|
side_effects: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
"use strict";
|
||||||
|
typeof a == 0;
|
||||||
|
console.log(typeof function a() {
|
||||||
|
let a;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
"use strict";
|
||||||
|
console.log(typeof function a() {
|
||||||
|
let a;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
expect_stdout: "function"
|
||||||
|
node_version: ">=4"
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user