OPT(AST_Try, function(self, compressor){
self.body = tighten_body(self.body, compressor);
+ if (self.bcatch && self.bfinally && all(self.bfinally.body, is_empty)) self.bfinally = null;
+ if (all(self.body, is_empty)) {
+ var body = [];
+ if (self.bcatch) extract_declarations_from_unreachable_code(compressor, self.bcatch, body);
+ if (self.bfinally) body = body.concat(self.bfinally.body);
+ return body.length > 0 ? make_node(AST_BlockStatement, self, {
+ body: body
+ }).optimize(compressor) : make_node(AST_EmptyStatement, self);
+ }
return self;
});
input: {
function f() {
try {
+ x();
} catch (err) {
console.log(err.message);
}
}
}
- expect_exact: "function f(){try{}catch(c){console.log(c.message)}}"
- expect_stdout: true
+ expect_exact: "function f(){try{x()}catch(c){console.log(c.message)}}"
}
issue_1586_2: {
input: {
function f() {
try {
+ x();
} catch (err) {
console.log(err.message);
}
}
}
- expect_exact: "function f(){try{}catch(c){console.log(c.message)}}"
- expect_stdout: true
+ expect_exact: "function f(){try{x()}catch(c){console.log(c.message)}}"
}