Skip to content

Commit 3805754

Browse files
committed
throw on star reexports from dynamic modules
1 parent 0754a8a commit 3805754

File tree

1 file changed

+14
-19
lines changed

1 file changed

+14
-19
lines changed

spec.html

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8450,17 +8450,6 @@ <h1>Module Namespace Exotic Objects</h1>
84508450
A List containing the String values of the exported names exposed as own properties of this object. The list is ordered as if an Array of those String values had been sorted using `Array.prototype.sort` using *undefined* as _comparefn_.
84518451
</td>
84528452
</tr>
8453-
<tr>
8454-
<td>
8455-
[[HostDefined]]
8456-
</td>
8457-
<td>
8458-
Any, default value is *undefined*.
8459-
</td>
8460-
<td>
8461-
Field reserved for use by host environments that need to associate additional information with a Module Namespace Exotic Object.
8462-
</td>
8463-
</tr>
84648453
<tr>
84658454
<td>
84668455
[[Prototype]]
@@ -8617,7 +8606,6 @@ <h1>ModuleNamespaceCreate ( _module_, _exports_ )</h1>
86178606
1. Otherwise,
86188607
1. Let _sortedExports_ be a new List containing the same values as the list _exports_ where the values are ordered as if an Array of the same values had been sorted using `Array.prototype.sort` using *undefined* as _comparefn_.
86198608
1. Set _M_.[[Exports]] to _sortedExports_.
8620-
1. Set _M_.[[HostDefined]] to *undefined*.
86218609
1. Create own properties of _M_ corresponding to the definitions in <emu-xref href="#sec-module-namespace-objects"></emu-xref>.
86228610
1. Set _module_.[[Namespace]] to _M_.
86238611
1. Return _M_.
@@ -21436,7 +21424,7 @@ <h1>Abstract Module Records</h1>
2143621424
</tr>
2143721425
<tr>
2143821426
<td>
21439-
GetExportedNames(_exportStarSet_, _nsModule_)
21427+
GetExportedNames(_exportStarSet_)
2144021428
</td>
2144121429
<td>
2144221430
Return a list of all names that are either directly or indirectly exported from this module.
@@ -22028,12 +22016,11 @@ <h1>ParseModule ( _sourceText_, _realm_, _hostDefined_ )</h1>
2202822016
</emu-clause>
2202922017

2203022018
<emu-clause id="sec-getexportednames">
22031-
<h1>GetExportedNames ( _exportStarSet_, _nsModule_ ) Concrete Method</h1>
22019+
<h1>GetExportedNames ( _exportStarSet_ ) Concrete Method</h1>
2203222020
<p>The GetExportedNames concrete method of a Source Text Module Record implements the corresponding Module Record abstract method.</p>
2203322021
<p>It performs the following steps:</p>
2203422022
<emu-alg>
2203522023
1. Assert: _exportStarSet_ is a List of Module Records.
22036-
1. Assert: _nsModule_ is a Module Record.
2203722024
1. Let _module_ be this Source Text Module Record.
2203822025
1. If _exportStarSet_ contains _module_, then
2203922026
1. Assert: We've reached the starting point of an `import *` circularity.
@@ -22048,17 +22035,17 @@ <h1>GetExportedNames ( _exportStarSet_, _nsModule_ ) Concrete Method</h1>
2204822035
1. Append _e_.[[ExportName]] to _exportedNames_.
2204922036
1. For each ExportEntry Record _e_ in _module_.[[StarExportEntries]], do
2205022037
1. Let _requestedModule_ be ? HostResolveImportedModule(_module_, _e_.[[ModuleRequest]]).
22051-
1. Let _starNames_ be ? _requestedModule_.GetExportedNames(_exportStarSet_, _nsModule_).
22038+
1. Let _starNames_ be ? _requestedModule_.GetExportedNames(_exportStarSet_).
2205222039
1. If _starNames_ is *null*, then
22053-
1. Return *null*.
22040+
1. Return *null*.
2205422041
1. For each element _n_ of _starNames_, do
2205522042
1. If SameValue(_n_, `"default"`) is *false*, then
2205622043
1. If _n_ is not an element of _exportedNames_, then
2205722044
1. Append _n_ to _exportedNames_.
2205822045
1. Return _exportedNames_.
2205922046
</emu-alg>
2206022047
<emu-note>
22061-
<p>GetExportedNames does not filter out or throw an exception for names that have ambiguous star export bindings.</p>
22048+
<p>GetExportedNames does not filter out or throw an exception for names that have ambiguous star export bindings. It also doesn't throw for modules that star export from non-source text Module Records with deferred bindings.</p>
2206222049
</emu-note>
2206322050
</emu-clause>
2206422051

@@ -22204,6 +22191,11 @@ <h1>ModuleDeclarationEnvironmentSetup ( _module_ )</h1>
2220422191
1. Let _resolution_ be ? _importedModule_.ResolveExport(_in_.[[ImportName]], &laquo; &raquo;).
2220522192
1. If _resolution_ is *null* or `"ambiguous"`, throw a *SyntaxError* exception.
2220622193
1. Call _envRec_.CreateImportBinding(_in_.[[LocalName]], _resolution_.[[Module]], _resolution_.[[BindingName]]).
22194+
1. For each ExportEntry Record _e_ in _module_.[[StarExportEntries]], do
22195+
1. Let _requestedModule_ be ? HostResolveImportedModule(_module_, _e_.[[ModuleRequest]]).
22196+
1. Let _exportNames_ be ? _requestedModule_.GetExportedNames(_exportStarSet_).
22197+
1. If _exportNames_ is *null*, then
22198+
1. Throw a *SyntaxError* exception.
2220722199
1. Let _code_ be _module_.[[ECMAScriptCode]].
2220822200
1. Let _varDeclarations_ be the VarScopedDeclarations of _code_.
2220922201
1. Let _declaredVarNames_ be a new empty List.
@@ -22225,6 +22217,9 @@ <h1>ModuleDeclarationEnvironmentSetup ( _module_ )</h1>
2222522217
1. Call _envRec_.InitializeBinding(_dn_, _fo_).
2222622218
1. Return NormalCompletion(~empty~).
2222722219
</emu-alg>
22220+
<emu-note>
22221+
<p>A *null* return from GetExportedNames indicates a non-source text Module Record with deferred exports. Star exports from these modules are not supported and throw a Syntax Error.</p>
22222+
</emu-note>
2222822223
</emu-clause>
2222922224
</emu-clause>
2223022225

@@ -22398,7 +22393,7 @@ <h1>Runtime Semantics: GetModuleNamespace ( _module_ )</h1>
2239822393
1. Assert: _module_.[[Status]] is not `"uninstantiated"`.
2239922394
1. Let _namespace_ be _module_.[[Namespace]].
2240022395
1. If _namespace_ is *undefined*, then
22401-
1. Let _exportedNames_ be ? _module_.GetExportedNames(&laquo; &raquo;, _module_).
22396+
1. Let _exportedNames_ be ? _module_.GetExportedNames(&laquo; &raquo;).
2240222397
1. If _exportedNames_ is *null*, then
2240322398
1. Set _namespace_ to ModuleNamespaceCreate(_module_, *null*).
2240422399
1. Otherwise,

0 commit comments

Comments
 (0)