Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Normative: GetExportedNames adjustments for late-defined export names #1306

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 35 additions & 12 deletions spec.html
Original file line number Diff line number Diff line change
Expand Up @@ -8444,10 +8444,10 @@ <h1>Module Namespace Exotic Objects</h1>
[[Exports]]
</td>
<td>
List of String
List of String | Null
</td>
<td>
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_.
A List containing the String values of the exported names exposed as own properties of this object. A *null* value indicates a non-Source-Text Module Record with deferred export bindings. The list is ordered as if an Array of those String values had been sorted using `Array.prototype.sort` using *undefined* as _comparefn_.
</td>
</tr>
<tr>
Expand Down Expand Up @@ -8478,6 +8478,8 @@ <h1>[[SetPrototypeOf]] ( _V_ )</h1>
<h1>[[IsExtensible]] ( )</h1>
<p>When the [[IsExtensible]] internal method of a module namespace exotic object _O_ is called, the following steps are taken:</p>
<emu-alg>
1. If _O_.[[Exports]] is *null*, then
1. Return *true*.
1. Return *false*.
</emu-alg>
</emu-clause>
Expand All @@ -8486,6 +8488,8 @@ <h1>[[IsExtensible]] ( )</h1>
<h1>[[PreventExtensions]] ( )</h1>
<p>When the [[PreventExtensions]] internal method of a module namespace exotic object _O_ is called, the following steps are taken:</p>
<emu-alg>
1. If _O_.[[Exports]] is *null*, then
1. Return *false*.
1. Return *true*.
</emu-alg>
</emu-clause>
Expand All @@ -8506,7 +8510,9 @@ <h1>[[GetOwnProperty]] ( _P_ )</h1>
<h1>[[DefineOwnProperty]] ( _P_, _Desc_ )</h1>
<p>When the [[DefineOwnProperty]] internal method of a module namespace exotic object _O_ is called with property key _P_ and Property Descriptor _Desc_, the following steps are taken:</p>
<emu-alg>
1. If Type(_P_) is Symbol, return OrdinaryDefineOwnProperty(_O_, _P_, _Desc_).
1. If Type(_P_) is Symbol, then
1. Let _current_ be ? _O_.[[GetOwnProperty]](_P_).
1. Return ValidateAndApplyPropertyDescriptor(_O_, _P_, *false*, _Desc_, _current_).
1. Let _current_ be ? _O_.[[GetOwnProperty]](_P_).
1. If _current_ is *undefined*, return *false*.
1. If IsAccessorDescriptor(_Desc_) is *true*, return *false*.
Expand Down Expand Up @@ -8591,12 +8597,15 @@ <h1>ModuleNamespaceCreate ( _module_, _exports_ )</h1>
<emu-alg>
1. Assert: _module_ is a Module Record.
1. Assert: _module_.[[Namespace]] is *undefined*.
1. Assert: _exports_ is a List of String values.
1. Assert: _exports_ is either *null*, or a List of String values.
1. Let _M_ be a newly created object.
1. Set _M_'s essential internal methods to the definitions specified in <emu-xref href="#sec-module-namespace-exotic-objects"></emu-xref>.
1. Set _M_.[[Module]] to _module_.
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_.
1. Set _M_.[[Exports]] to _sortedExports_.
1. If _exports_ is *null*, then
1. Set _M_.[[Exports]] to *null*.
1. Otherwise,
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_.
1. Set _M_.[[Exports]] to _sortedExports_.
1. Create own properties of _M_ corresponding to the definitions in <emu-xref href="#sec-module-namespace-objects"></emu-xref>.
1. Set _module_.[[Namespace]] to _M_.
1. Return _M_.
guybedford marked this conversation as resolved.
Show resolved Hide resolved
Expand Down Expand Up @@ -22011,6 +22020,7 @@ <h1>GetExportedNames ( _exportStarSet_ ) Concrete Method</h1>
<p>The GetExportedNames concrete method of a Source Text Module Record implements the corresponding Module Record abstract method.</p>
<p>It performs the following steps:</p>
<emu-alg>
1. Assert: _exportStarSet_ is a List of Module Records.
1. Let _module_ be this Source Text Module Record.
1. If _exportStarSet_ contains _module_, then
1. Assert: We've reached the starting point of an `import *` circularity.
Expand All @@ -22026,14 +22036,16 @@ <h1>GetExportedNames ( _exportStarSet_ ) Concrete Method</h1>
1. For each ExportEntry Record _e_ in _module_.[[StarExportEntries]], do
1. Let _requestedModule_ be ? HostResolveImportedModule(_module_, _e_.[[ModuleRequest]]).
1. Let _starNames_ be ? _requestedModule_.GetExportedNames(_exportStarSet_).
1. If _starNames_ is *null*, then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also a change to STMR

1. Return *null*.
1. For each element _n_ of _starNames_, do
1. If SameValue(_n_, `"default"`) is *false*, then
1. If _n_ is not an element of _exportedNames_, then
1. Append _n_ to _exportedNames_.
1. Return _exportedNames_.
</emu-alg>
<emu-note>
<p>GetExportedNames does not filter out or throw an exception for names that have ambiguous star export bindings.</p>
<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>
</emu-note>
</emu-clause>

Expand Down Expand Up @@ -22179,6 +22191,11 @@ <h1>ModuleDeclarationEnvironmentSetup ( _module_ )</h1>
1. Let _resolution_ be ? _importedModule_.ResolveExport(_in_.[[ImportName]], &laquo; &raquo;).
1. If _resolution_ is *null* or `"ambiguous"`, throw a *SyntaxError* exception.
1. Call _envRec_.CreateImportBinding(_in_.[[LocalName]], _resolution_.[[Module]], _resolution_.[[BindingName]]).
1. For each ExportEntry Record _e_ in _module_.[[StarExportEntries]], do
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a change to Source Text Module Records, so I am unsure why you are saying there are no changes to STMR in this PR.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, yes, apologies I mispoke on that one.

1. Let _requestedModule_ be ? HostResolveImportedModule(_module_, _e_.[[ModuleRequest]]).
1. Let _exportNames_ be ? _requestedModule_.GetExportedNames(_exportStarSet_).
1. If _exportNames_ is *null*, then
1. Throw a *SyntaxError* exception.
1. Let _code_ be _module_.[[ECMAScriptCode]].
1. Let _varDeclarations_ be the VarScopedDeclarations of _code_.
1. Let _declaredVarNames_ be a new empty List.
Expand All @@ -22200,6 +22217,9 @@ <h1>ModuleDeclarationEnvironmentSetup ( _module_ )</h1>
1. Call _envRec_.InitializeBinding(_dn_, _fo_).
1. Return NormalCompletion(~empty~).
</emu-alg>
<emu-note>
<p>A *null* return from GetExportedNames indicates a non-Source Text Module Record with deferred exports. Star exports from these modules are not currently supported and throw a Syntax Error. This constraint could be removed in future.</p>
</emu-note>
</emu-clause>
</emu-clause>

Expand Down Expand Up @@ -22374,11 +22394,14 @@ <h1>Runtime Semantics: GetModuleNamespace ( _module_ )</h1>
1. Let _namespace_ be _module_.[[Namespace]].
1. If _namespace_ is *undefined*, then
ljharb marked this conversation as resolved.
Show resolved Hide resolved
1. Let _exportedNames_ be ? _module_.GetExportedNames(&laquo; &raquo;).
1. Let _unambiguousNames_ be a new empty List.
1. For each _name_ that is an element of _exportedNames_, do
1. Let _resolution_ be ? _module_.ResolveExport(_name_, &laquo; &raquo;).
1. If _resolution_ is a ResolvedBinding Record, append _name_ to _unambiguousNames_.
1. Set _namespace_ to ModuleNamespaceCreate(_module_, _unambiguousNames_).
1. If _exportedNames_ is *null*, then
1. Set _namespace_ to ModuleNamespaceCreate(_module_, *null*).
1. Otherwise,
1. Let _unambiguousNames_ be a new empty List.
1. For each _name_ in _exportedNames_, do
1. Let _resolution_ be ? _module_.ResolveExport(_name_, &laquo; &raquo;).
1. If _resolution_ is a ResolvedBinding Record, append _name_ to _unambiguousNames_.
1. Set _namespace_ to ModuleNamespaceCreate(_module_, _unambiguousNames_).
1. Return _namespace_.
</emu-alg>
<emu-note>
Expand Down