retrofit try-catch-finally as block-scoped (#4178)

- support optional catch binding
This commit is contained in:
Alex Lam S.L
2020-10-04 22:30:14 +01:00
committed by GitHub
parent f9946767c9
commit 8f0521d51d
8 changed files with 74 additions and 19 deletions

View File

@@ -4457,9 +4457,11 @@ merge(Compressor.prototype, {
walk_body(node, tw);
pop();
if (node.bcatch) {
var def = node.bcatch.argname.definition();
references[def.id] = false;
if (def = def.redefined()) references[def.id] = false;
if (node.bcatch.argname) {
var def = node.bcatch.argname.definition();
references[def.id] = false;
if (def = def.redefined()) references[def.id] = false;
}
push();
if (node.bfinally) segment.block = node.bcatch;
walk_body(node.bcatch, tw);
@@ -7055,7 +7057,7 @@ merge(Compressor.prototype, {
child = scope;
scope = compressor.parent(++level);
if (scope instanceof AST_Catch) {
catches[scope.argname.name] = true;
if (scope.argname) catches[scope.argname.name] = true;
} else if (scope instanceof AST_DWLoop) {
in_loop = [];
} else if (scope instanceof AST_For) {