Skip to content

Commit

Permalink
fix corner case in inline (#5742)
Browse files Browse the repository at this point in the history
fixes #5741
  • Loading branch information
alexlamsl authored Nov 22, 2022
1 parent 24c3db1 commit aef7065
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/compress.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
34 changes: 34 additions & 0 deletions test/compress/let.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}

0 comments on commit aef7065

Please sign in to comment.