diff --git a/lib/output.js b/lib/output.js index 6c056371..e66434a6 100644 --- a/lib/output.js +++ b/lib/output.js @@ -629,6 +629,15 @@ function OutputStream(options) { return false; }); + // Anonymous classes needs parens around when it's the first token in a statement. + PARENS(AST_Class, function(output){ + if (this.name === undefined && first_in_statement(output)) { + return true; + } + + return false; + }); + PARENS(AST_Arrow, function(output){ var p = output.parent(); return p instanceof AST_PropAccess && p.expression === this; diff --git a/test/compress/harmony.js b/test/compress/harmony.js index 7ed25210..92ae2e44 100644 --- a/test/compress/harmony.js +++ b/test/compress/harmony.js @@ -159,6 +159,17 @@ classes_with_expression_as_expand: { expect_exact: "class D extends(calls++,C){}" } +class_as_sequence_expression: { + options = { + side_effects: true + } + input: { + 0, class {} + 0, class A{} + } + expect_exact: "(class{});class A{};" +} + new_target: { input: { new.target;