Skip to content

Commit aef7065

Browse files
authoredNov 22, 2022
fix corner case in inline (#5742)
fixes #5741
1 parent 24c3db1 commit aef7065

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed
 

‎lib/compress.js

+1
Original file line numberDiff line numberDiff line change
@@ -11160,6 +11160,7 @@ Compressor.prototype.compress = function(node) {
1116011160
function append_var(decls, expressions, name, value) {
1116111161
var def = name.definition();
1116211162
if (!scope.var_names().has(name.name)) {
11163+
if (def.first_decl === name) def.first_decl = null;
1116311164
scope.var_names().set(name.name, true);
1116411165
decls.push(make_node(AST_VarDef, name, {
1116511166
name: name,

‎test/compress/let.js

+34
Original file line numberDiff line numberDiff line change
@@ -2294,3 +2294,37 @@ issue_5591: {
22942294
]
22952295
node_version: ">=4"
22962296
}
2297+
2298+
issue_5741: {
2299+
options = {
2300+
inline: true,
2301+
join_vars: true,
2302+
reduce_vars: true,
2303+
}
2304+
input: {
2305+
"use strict";
2306+
(function(a) {
2307+
let b = function() {
2308+
var c = a;
2309+
console.log(c);
2310+
}();
2311+
function g() {
2312+
a++;
2313+
b;
2314+
}
2315+
})("PASS");
2316+
}
2317+
expect: {
2318+
"use strict";
2319+
(function(a) {
2320+
let b = (c = a, void console.log(c));
2321+
var c;
2322+
function g() {
2323+
a++;
2324+
b;
2325+
}
2326+
})("PASS");
2327+
}
2328+
expect_stdout: "PASS"
2329+
node_version: ">=4"
2330+
}

0 commit comments

Comments
 (0)
Please sign in to comment.