fix undefined confusion with local variable

This commit is contained in:
alexlamsl 2017-04-02 13:57:28 +08:00
parent 3fc717a531
commit dd0e753e90
2 changed files with 28 additions and 2 deletions

View File

@ -1054,7 +1054,7 @@ merge(Compressor.prototype, {
stat.value = cons_seq(stat.value); stat.value = cons_seq(stat.value);
} }
else if (stat instanceof AST_Exit) { else if (stat instanceof AST_Exit) {
stat.value = cons_seq(make_node(AST_Undefined, stat)); stat.value = cons_seq(make_node(AST_Undefined, stat).transform(compressor));
} }
else if (stat instanceof AST_Switch) { else if (stat instanceof AST_Switch) {
stat.expression = cons_seq(stat.expression); stat.expression = cons_seq(stat.expression);
@ -2912,7 +2912,7 @@ merge(Compressor.prototype, {
if (name instanceof AST_SymbolRef if (name instanceof AST_SymbolRef
&& name.name == "console" && name.name == "console"
&& name.undeclared()) { && name.undeclared()) {
return make_node(AST_Undefined, self).transform(compressor); return make_node(AST_Undefined, self).optimize(compressor);
} }
} }
} }

View File

@ -440,3 +440,29 @@ func_def_5: {
} }
expect_stdout: "true" expect_stdout: "true"
} }
issue_1758: {
options = {
sequences: true,
side_effects: true,
}
input: {
console.log(function(c) {
var undefined = 42;
return function() {
c--;
c--, c.toString();
return;
}();
}());
}
expect:{
console.log(function(c) {
var undefined = 42;
return function() {
return c--, c--, c.toString(), void 0;
}();
}());
}
expect_stdout: "undefined"
}