google / traceur-compiler

Traceur is a JavaScript.next-to-JavaScript-of-today compiler
Apache License 2.0
8.18k stars 580 forks source link

Ensure export star does not export default #1914

Closed guybedford closed 9 years ago

guybedford commented 9 years ago

Export * is not supposed to export the default export.

15.2.1.16.2 GetExportedNames( exportStarSet ) Concrete Method

For each ExportEntry Record e in module.[[StarExportEntries]], do Let requestedModule be HostResolveImportedModule(module, e.[[ModuleRequest]]). ReturnIfAbrupt(requestedModule). Let starNames be requestedModule.GetExportedNames(exportStarSet). For each element n of starNames, do If SameValue(n, "default") is false, then If n is not an element of exportedNames, then Append n to exportedNames.

15.2.1.16.3 ResolveExport( exportName, resolveSet, exportStarSet ) Concrete Method

If SameValue(exportName, "default") is true, then Assert: A default export was not explicitly defined by this module. Throw a SyntaxError exception. NOTE A default export cannot be provided by an export *.

arv commented 9 years ago

Can you add a feature test too?

guybedford commented 9 years ago

Can you clarify what you'd need? That test case does provide full coverage.

arv commented 9 years ago

I don't see how it fixes the same issue for the other module formats?

We prefer writing tests in test/feature/ if possible since they are easier to maintain.

guybedford commented 9 years ago

Sure, I've updated it to cover the other module formats as well.

arv commented 9 years ago

Thanks you. LGTM