Skip to content

Commit

Permalink
fix: missing compressor arg in optimize AST_VarDef (#1009)
Browse files Browse the repository at this point in the history
  • Loading branch information
bastimeyer committed Jun 27, 2021
1 parent 60a74bb commit 215db3c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/compress/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5102,11 +5102,11 @@ def_optimize(AST_Definitions, function(self) {
return self;
});

def_optimize(AST_VarDef, function(self) {
def_optimize(AST_VarDef, function(self, compressor) {
if (
self.name instanceof AST_SymbolLet
&& self.value != null
&& is_undefined(self.value)
&& is_undefined(self.value, compressor)
) {
self.value = null;
}
Expand Down
24 changes: 24 additions & 0 deletions test/compress/issue-1006.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
issue_1006: {
options = {
defaults: true,
}
input: {
function func(foo) {
function bar() {
return;
}
let baz = foo();
if (baz !== undefined) {
let qux = bar(baz.qux);
}
}
}
expect: {
function func(foo) {
let baz = foo();
if (void 0 !== baz) {
baz.qux;
}
}
}
}

0 comments on commit 215db3c

Please sign in to comment.