diff --git a/src/statement.js b/src/statement.js index e90e97b489..7ac5484ec4 100644 --- a/src/statement.js +++ b/src/statement.js @@ -458,14 +458,14 @@ pp.parseExport = function(node) { } if (this.eat(tt._default)) { // export default ... let expr = this.parseMaybeAssign() - if (expr.id) { - switch (expr.type) { + let needsSemi = false + if (expr.id) switch (expr.type) { case "FunctionExpression": expr.type = "FunctionDeclaration"; break case "ClassExpression": expr.type = "ClassDeclaration"; break - } + default: needsSemi = true } node.declaration = expr - this.semicolon() + if (needsSemi) this.semicolon() return this.finishNode(node, "ExportDefaultDeclaration") } // export var|const|let|function|class ... diff --git a/test/tests-harmony.js b/test/tests-harmony.js index 71b9be9c08..03a4a54c25 100644 --- a/test/tests-harmony.js +++ b/test/tests-harmony.js @@ -15596,3 +15596,32 @@ test("new.target", { }, {ecmaVersion: 6}); testFail("new.prop", "The only valid meta property for new is new.target (1:4)", {ecmaVersion: 6}); + +test("export default function () {} false", { + body: [ + { + declaration: { + id: null, + generator: false, + expression: false, + params: [], + body: { + body: [], + type: "BlockStatement" + }, + type: "FunctionExpression" + }, + type: "ExportDefaultDeclaration" + }, + { + expression: { + value: false, + raw: "false", + type: "Literal" + }, + type: "ExpressionStatement" + } + ], + sourceType: "module", + type: "Program" +}, {ecmaVersion: 6, sourceType: "module"})