--- /dev/null
+try {
+ "foo" in 42;
+} catch ({
+ message,
+}) {
+ console.log(message);
+}
--- /dev/null
+// (beautified)
+try {
+ 1 in 0;
+} catch ({
+ message: message
+}) {
+ console.log(message);
+}
+// output: Cannot use 'in' operator to search for '1' in 0
+//
+// minify: Cannot use 'in' operator to search for '0' in 0
+//
+// options: {
+// "mangle": false
+// }
\ No newline at end of file
if (result.error) throw result.error;
assert.strictEqual(result.code, read("test/input/reduce/diff_error.reduced.js"));
});
+ it("Should handle destructured catch expressions", function() {
+ if (semver.satisfies(process.version, "<6")) return;
+ var result = reduce_test(read("test/input/reduce/destructured_catch.js"), {
+ mangle: false,
+ });
+ if (result.error) throw result.error;
+ assert.strictEqual(result.code, read("test/input/reduce/destructured_catch.reduced.js"));
+ });
});
if (node.TYPE == "Call" && node.expression.print_to_string() == "console.log") {
return to_sequence(node.args);
}
- if (node instanceof U.AST_Catch && node.argname) {
+ if (node instanceof U.AST_Catch && node.argname instanceof U.AST_SymbolCatch) {
descend(node, this);
node.body.unshift(new U.AST_SimpleStatement({
body: wrap_with_console_log(new U.AST_SymbolRef(node.argname)),
offset: 0,
tries: [],
} ];
- var re = /(?:(?:^|[\s{}):;])try|}\s*catch\s*\(([^)]+)\)|}\s*finally)\s*(?={)/g;
+ var re = /(?:(?:^|[\s{}):;])try|}\s*catch\s*\(([^)[{]+)\)|}\s*finally)\s*(?={)/g;
while (stack.length) {
var code = stack[0].code;
var offset = stack[0].offset;