check valid function/class token when parsing export default before converting to a declaration - fixes #2145

This commit is contained in:
Sebastian McKenzie
2015-08-02 21:36:52 +01:00
parent a0f9d5fbc8
commit 94e345e0b2
7 changed files with 207 additions and 1 deletions

View File

@@ -648,9 +648,10 @@ pp.parseExport = function (node) {
}
this.parseExportFrom(node, true);
} else if (this.eat(tt._default)) { // export default ...
let possibleDeclaration = this.match(tt._function) || this.match(tt._class);
let expr = this.parseMaybeAssign();
let needsSemi = true;
if (expr.type === "FunctionExpression" || expr.type === "ClassExpression") {
if (possibleDeclaration) {
needsSemi = false;
if (expr.id) {
expr.type = expr.type === "FunctionExpression" ? "FunctionDeclaration" : "ClassDeclaration";