diff --git a/lib/output.js b/lib/output.js index 42137606..688a0b15 100644 --- a/lib/output.js +++ b/lib/output.js @@ -637,6 +637,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 95ba07eb..a09e1b57 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;