mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-30 13:45:27 +00:00
Bug 1287406 - Fix exporting an arrow function as the default export r=shu
This commit is contained in:
parent
a608f3180b
commit
7c272adaa9
@ -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);
|
||||
|
1
js/src/jit-test/tests/modules/bug-1287406.js
Normal file
1
js/src/jit-test/tests/modules/bug-1287406.js
Normal file
@ -0,0 +1 @@
|
||||
parseModule("export default () => 1");
|
Loading…
Reference in New Issue
Block a user