fix corner case in inline (#5742)

fixes #5741
This commit is contained in:
Alex Lam S.L
2022-11-23 01:26:08 +02:00
committed by GitHub
parent 24c3db11e6
commit aef7065262
2 changed files with 35 additions and 0 deletions

View File

@@ -11160,6 +11160,7 @@ Compressor.prototype.compress = function(node) {
function append_var(decls, expressions, name, value) {
var def = name.definition();
if (!scope.var_names().has(name.name)) {
if (def.first_decl === name) def.first_decl = null;
scope.var_names().set(name.name, true);
decls.push(make_node(AST_VarDef, name, {
name: name,

View File

@@ -2294,3 +2294,37 @@ issue_5591: {
]
node_version: ">=4"
}
issue_5741: {
options = {
inline: true,
join_vars: true,
reduce_vars: true,
}
input: {
"use strict";
(function(a) {
let b = function() {
var c = a;
console.log(c);
}();
function g() {
a++;
b;
}
})("PASS");
}
expect: {
"use strict";
(function(a) {
let b = (c = a, void console.log(c));
var c;
function g() {
a++;
b;
}
})("PASS");
}
expect_stdout: "PASS"
node_version: ">=4"
}