improve handling of non-trivial assignment values (#5227)

This commit is contained in:
Alex Lam S.L
2021-12-22 23:55:06 +00:00
committed by GitHub
parent 343bf6d7a5
commit 7b2eb4b5ff
13 changed files with 423 additions and 217 deletions

View File

@@ -3039,18 +3039,17 @@ issue_2437: {
console.log(foo());
}
expect: {
console.log(function() {
if (xhrDesc) {
var result = !!(req = new XMLHttpRequest()).onreadystatechange;
return Object.defineProperty(XMLHttpRequest.prototype, "onreadystatechange", xhrDesc || {}),
result;
}
function detectFunc() {}
var req = new XMLHttpRequest();
return req.onreadystatechange = detectFunc,
result = req[SYMBOL_FAKE_ONREADYSTATECHANGE_1] === detectFunc,
req.onreadystatechange = null, result;
}());
var req, detectFunc, result;
console.log((
xhrDesc ? (
result = !!(req = new XMLHttpRequest).onreadystatechange,
Object.defineProperty(XMLHttpRequest.prototype, "onreadystatechange", xhrDesc || {})
) : (
(req = new XMLHttpRequest).onreadystatechange = detectFunc = function(){},
result = req[SYMBOL_FAKE_ONREADYSTATECHANGE_1] === detectFunc,req.onreadystatechange = null
),
result
));
}
}
@@ -3826,16 +3825,14 @@ inlined_single_use: {
}
expect: {
console.log(function(f) {
var a = function() {
a = function() {
A;
};
var b = function() {
},
b = function() {
a(B);
};
(function() {
b;
});
return;
},
void 0;
var a, b;
}());
}
expect_stdout: "undefined"
@@ -5290,6 +5287,42 @@ direct_inline_catch_redefined: {
expect_stdout: true
}
statement_var_inline: {
options = {
inline: true,
join_vars: true,
unused: true,
}
input: {
function f() {
(function() {
var a = {};
function g() {
a.p;
}
g(console.log("PASS"));
var b = function h(c) {
c && c.q;
}();
})();
}
f();
}
expect: {
function f() {
var c, a = {};
function g() {
a.p;
}
g(console.log("PASS"));
c && c.q;
return;
}
f();
}
expect_stdout: "PASS"
}
issue_4171_1: {
options = {
functions: true,