@@ -5789,7 +5789,7 @@ merge(Compressor.prototype, {
|
|||||||
if (!tail_refs) continue;
|
if (!tail_refs) continue;
|
||||||
if (head_refs.start.block !== tail_refs.start.block
|
if (head_refs.start.block !== tail_refs.start.block
|
||||||
|| !mergeable(head_refs, tail_refs)
|
|| !mergeable(head_refs, tail_refs)
|
||||||
|| head_refs.start.loop && !mergeable(tail_refs, head_refs)
|
|| (head_refs.start.loop || !same_scope(def)) && !mergeable(tail_refs, head_refs)
|
||||||
|| !all(tail_refs, function(sym) {
|
|| !all(tail_refs, function(sym) {
|
||||||
return sym.scope.find_variable(def.name) === def;
|
return sym.scope.find_variable(def.name) === def;
|
||||||
})) {
|
})) {
|
||||||
|
|||||||
@@ -3301,3 +3301,80 @@ issue_4761: {
|
|||||||
}
|
}
|
||||||
expect_stdout: "undefined"
|
expect_stdout: "undefined"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
issue_4956_1: {
|
||||||
|
options = {
|
||||||
|
merge_vars: true,
|
||||||
|
toplevel: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
var a, b;
|
||||||
|
function f(c) {
|
||||||
|
switch (c) {
|
||||||
|
case 0:
|
||||||
|
a = { p: 42 };
|
||||||
|
|
||||||
|
case 1:
|
||||||
|
b = a.p;
|
||||||
|
console.log(b);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
f(0);
|
||||||
|
f(1);
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
var a, b;
|
||||||
|
function f(c) {
|
||||||
|
switch (c) {
|
||||||
|
case 0:
|
||||||
|
a = { p: 42 };
|
||||||
|
|
||||||
|
case 1:
|
||||||
|
b = a.p;
|
||||||
|
console.log(b);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
f(0);
|
||||||
|
f(1);
|
||||||
|
}
|
||||||
|
expect_stdout: [
|
||||||
|
"42",
|
||||||
|
"42",
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
issue_4956_2: {
|
||||||
|
options = {
|
||||||
|
merge_vars: true,
|
||||||
|
toplevel: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
var a, b;
|
||||||
|
function f(c) {
|
||||||
|
if (0 == c) {
|
||||||
|
console;
|
||||||
|
a = { p: 42 };
|
||||||
|
}
|
||||||
|
b = a.p;
|
||||||
|
if (1 == c)
|
||||||
|
console.log(b);
|
||||||
|
}
|
||||||
|
f(0);
|
||||||
|
f(1);
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
var a, b;
|
||||||
|
function f(c) {
|
||||||
|
if (0 == c) {
|
||||||
|
console;
|
||||||
|
a = { p: 42 };
|
||||||
|
}
|
||||||
|
b = a.p;
|
||||||
|
if (1 == c)
|
||||||
|
console.log(b);
|
||||||
|
}
|
||||||
|
f(0);
|
||||||
|
f(1);
|
||||||
|
}
|
||||||
|
expect_stdout: "42"
|
||||||
|
}
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ exports.run_code = semver.satisfies(process.version, "0.8") ? function(code, top
|
|||||||
} : semver.satisfies(process.version, "<0.12") ? run_code_vm : function(code, toplevel, timeout) {
|
} : semver.satisfies(process.version, "<0.12") ? run_code_vm : function(code, toplevel, timeout) {
|
||||||
if ([
|
if ([
|
||||||
/\basync[ \t]*\([\s\S]*?\)[ \t]*=>/,
|
/\basync[ \t]*\([\s\S]*?\)[ \t]*=>/,
|
||||||
/\b(async[ \t]+function|setImmediate|setInterval|setTimeout)\b/,
|
/\b(async[ \t]+function|Promise|setImmediate|setInterval|setTimeout)\b/,
|
||||||
/\basync([ \t]+|[ \t]*#|[ \t]*\*[ \t]*)[^\s()[\]{},.&|!~=*%/+-]+(\s*\(|[ \t]*=>)/,
|
/\basync([ \t]+|[ \t]*#|[ \t]*\*[ \t]*)[^\s()[\]{},.&|!~=*%/+-]+(\s*\(|[ \t]*=>)/,
|
||||||
].some(function(pattern) {
|
].some(function(pattern) {
|
||||||
return pattern.test(code);
|
return pattern.test(code);
|
||||||
|
|||||||
Reference in New Issue
Block a user