Bug 1287406 - Fix exporting an arrow function as the default export r=shu

This commit is contained in:
Jon Coppeard 2016-08-02 10:35:16 +01:00
parent a608f3180b
commit 7c272adaa9
2 changed files with 15 additions and 9 deletions

View File

@ -1153,15 +1153,6 @@ ModuleBuilder::processExport(frontend::ParseNode* pn)
}
break;
case PNK_FUNCTION: {
RootedFunction func(cx_, kid->pn_funbox->function());
RootedAtom localName(cx_, func->name());
RootedAtom exportName(cx_, isDefault ? cx_->names().default_ : localName.get());
if (!appendExportEntry(exportName, localName))
return false;
break;
}
case PNK_CLASS: {
const ClassNode& cls = kid->as<ClassNode>();
MOZ_ASSERT(cls.names());
@ -1188,6 +1179,20 @@ ModuleBuilder::processExport(frontend::ParseNode* pn)
break;
}
case PNK_FUNCTION: {
RootedFunction func(cx_, kid->pn_funbox->function());
if (!func->isArrow()) {
RootedAtom localName(cx_, func->name());
RootedAtom exportName(cx_, isDefault ? cx_->names().default_ : localName.get());
MOZ_ASSERT_IF(isDefault, localName);
if (!appendExportEntry(exportName, localName))
return false;
break;
}
}
MOZ_FALLTHROUGH; // Arrow functions are handled below.
default:
MOZ_ASSERT(isDefault);
RootedAtom localName(cx_, cx_->names().starDefaultStar);

View File

@ -0,0 +1 @@
parseModule("export default () => 1");