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

Editorial: mostly stop using strings for special values #2566

Merged
merged 5 commits into from
Nov 5, 2021
Merged
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
55 changes: 29 additions & 26 deletions spec.html
Original file line number Diff line number Diff line change
Expand Up @@ -7215,8 +7215,8 @@ <h1>Scope Analysis</h1>
<h1>Static Semantics: BoundNames</h1>
<dl class="header">
</dl>
<emu-note>
<p>*"\*default\*"* is used within this specification as a synthetic name for hoistable anonymous functions that are defined using export declarations.</p>
<emu-note id="note-star-default-star">
<p>*"\*default\*"* is used within this specification as a synthetic name for a module's default export when it does not have another name. An entry in the module's [[Environment]] is created with that name and holds the corresponding value, and resolving the export named *"default"* by calling <emu-xref href="#sec-resolveexport" title></emu-xref> for the module will return a ResolvedBinding Record whose [[BindingName]] is *"\*default\*"*, which will then resolve in the module's [[Environment]] to the above-mentioned value. This is done only for ease of specification, so that anonymous default exports can be resolved like any other export. The string *"\*default\*"* is never accessible to user code or to the module linking algorithm.</p>
</emu-note>
<emu-grammar>BindingIdentifier : Identifier</emu-grammar>
<emu-alg>
Expand Down Expand Up @@ -14941,7 +14941,7 @@ <h1>
1. Assert: _binding_ is a ResolvedBinding Record.
1. Let _targetModule_ be _binding_.[[Module]].
1. Assert: _targetModule_ is not *undefined*.
1. If _binding_.[[BindingName]] is *"\*namespace\*"*, then
1. If _binding_.[[BindingName]] is ~namespace~, then
1. Return ? GetModuleNamespace(_targetModule_).
1. Let _targetEnv_ be _targetModule_.[[Environment]].
1. If _targetEnv_ is ~empty~, throw a *ReferenceError* exception.
Expand Down Expand Up @@ -26140,7 +26140,7 @@ <h1>Abstract Module Records</h1>
ResolveExport(_exportName_ [, _resolveSet_])
</td>
<td>
<p>Return the binding of a name exported by this module. Bindings are represented by a <dfn id="resolvedbinding-record" variants="ResolvedBinding Records">ResolvedBinding Record</dfn>, of the form { [[Module]]: Module Record, [[BindingName]]: String }. If the export is a Module Namespace Object without a direct binding in any module, [[BindingName]] will be set to *"\*namespace\*"*. Return *null* if the name cannot be resolved, or *"ambiguous"* if multiple bindings were found.</p>
<p>Return the binding of a name exported by this module. Bindings are represented by a <dfn id="resolvedbinding-record" variants="ResolvedBinding Records">ResolvedBinding Record</dfn>, of the form { [[Module]]: Module Record, [[BindingName]]: String | ~namespace~ }. If the export is a Module Namespace Object without a direct binding in any module, [[BindingName]] will be set to ~namespace~. Return *null* if the name cannot be resolved, or ~ambiguous~ if multiple bindings were found.</p>
<p>Each time this operation is called with a specific _exportName_, _resolveSet_ pair as arguments it must return the same result if it completes normally.</p>
</td>
</tr>
Expand Down Expand Up @@ -27196,10 +27196,10 @@ <h1>Source Text Module Records</h1>
[[ImportName]]
</td>
<td>
String
String | ~namespace-object~
</td>
<td>
The name under which the desired binding is exported by the module identified by [[ModuleRequest]]. The value *"\*"* indicates that the import request is for the target module's namespace object.
The name under which the desired binding is exported by the module identified by [[ModuleRequest]]. The value ~namespace-object~ indicates that the import request is for the target module's namespace object.
</td>
</tr>
<tr>
Expand Down Expand Up @@ -27257,7 +27257,7 @@ <h1>Source Text Module Records</h1>
*"mod"*
</td>
<td>
*"\*"*
~namespace-object~
</td>
<td>
*"ns"*
Expand Down Expand Up @@ -27345,10 +27345,10 @@ <h1>Source Text Module Records</h1>
[[ImportName]]
</td>
<td>
String | null
String | null | ~all~ | ~all-but-default~
</td>
<td>
The name under which the desired binding is exported by the module identified by [[ModuleRequest]]. *null* if the |ExportDeclaration| does not have a |ModuleSpecifier|. *"\*"* indicates that the export request is for all exported bindings.
The name under which the desired binding is exported by the module identified by [[ModuleRequest]]. *null* if the |ExportDeclaration| does not have a |ModuleSpecifier|. ~all~ is used for `export * as ns from "mod"` declarations. ~all-but-default~ is used for `export * from "mod"` declarations.
</td>
</tr>
<tr>
Expand Down Expand Up @@ -27534,7 +27534,7 @@ <h1>Source Text Module Records</h1>
*"mod"*
</td>
<td>
*"\*"*
~all-but-default~
</td>
<td>
*null*
Expand All @@ -27551,7 +27551,7 @@ <h1>Source Text Module Records</h1>
*"mod"*
</td>
<td>
*"\*"*
~all~
</td>
<td>
*null*
Expand Down Expand Up @@ -27591,13 +27591,14 @@ <h1>
1. Append _ee_ to _localExportEntries_.
1. Else,
1. Let _ie_ be the element of _importEntries_ whose [[LocalName]] is the same as _ee_.[[LocalName]].
1. If _ie_.[[ImportName]] is *"\*"*, then
1. If _ie_.[[ImportName]] is ~namespace-object~, then
1. NOTE: This is a re-export of an imported module namespace object.
1. Append _ee_ to _localExportEntries_.
1. Else,
1. NOTE: This is a re-export of a single name.
1. Append the ExportEntry Record { [[ModuleRequest]]: _ie_.[[ModuleRequest]], [[ImportName]]: _ie_.[[ImportName]], [[LocalName]]: *null*, [[ExportName]]: _ee_.[[ExportName]] } to _indirectExportEntries_.
1. Else if _ee_.[[ImportName]] is *"\*"* and _ee_.[[ExportName]] is *null*, then
1. Else if _ee_.[[ImportName]] is ~all-but-default~, then
1. Assert: _ee_.[[ExportName]] is *null*.
1. Append _ee_ to _starExportEntries_.
1. Else,
1. Append _ee_ to _indirectExportEntries_.
Expand Down Expand Up @@ -27660,7 +27661,7 @@ <h1>
<dt>description</dt>
<dd>
<p>ResolveExport attempts to resolve an imported binding to the actual defining module and local binding name. The defining module may be the module represented by the Module Record this method was invoked on or some other module that is imported by that module. The parameter _resolveSet_ is used to detect unresolved circular import/export paths. If a pair consisting of specific Module Record and _exportName_ is reached that is already in _resolveSet_, an import circularity has been encountered. Before recursively calling ResolveExport, a pair consisting of _module_ and _exportName_ is added to _resolveSet_.</p>
<p>If a defining module is found, a ResolvedBinding Record { [[Module]], [[BindingName]] } is returned. This record identifies the resolved binding of the originally requested export, unless this is the export of a namespace with no local binding. In this case, [[BindingName]] will be set to *"\*namespace\*"*. If no definition was found or the request is found to be circular, *null* is returned. If the request is found to be ambiguous, the string *"ambiguous"* is returned.</p>
<p>If a defining module is found, a ResolvedBinding Record { [[Module]], [[BindingName]] } is returned. This record identifies the resolved binding of the originally requested export, unless this is the export of a namespace with no local binding. In this case, [[BindingName]] will be set to ~namespace~. If no definition was found or the request is found to be circular, *null* is returned. If the request is found to be ambiguous, ~ambiguous~ is returned.</p>
</dd>
</dl>

Expand All @@ -27678,9 +27679,9 @@ <h1>
1. For each ExportEntry Record _e_ of _module_.[[IndirectExportEntries]], do
1. If SameValue(_exportName_, _e_.[[ExportName]]) is *true*, then
1. Let _importedModule_ be ? HostResolveImportedModule(_module_, _e_.[[ModuleRequest]]).
1. If _e_.[[ImportName]] is *"\*"*, then
1. If _e_.[[ImportName]] is ~all~, then
1. Assert: _module_ does not provide the direct binding for this export.
1. Return ResolvedBinding Record { [[Module]]: _importedModule_, [[BindingName]]: *"\*namespace\*"* }.
1. Return ResolvedBinding Record { [[Module]]: _importedModule_, [[BindingName]]: ~namespace~ }.
1. Else,
1. Assert: _module_ imports a specific binding for this export.
1. Return _importedModule_.ResolveExport(_e_.[[ImportName]], _resolveSet_).
Expand All @@ -27692,13 +27693,15 @@ <h1>
1. For each ExportEntry Record _e_ of _module_.[[StarExportEntries]], do
1. Let _importedModule_ be ? HostResolveImportedModule(_module_, _e_.[[ModuleRequest]]).
1. Let _resolution_ be ? _importedModule_.ResolveExport(_exportName_, _resolveSet_).
1. If _resolution_ is *"ambiguous"*, return *"ambiguous"*.
1. If _resolution_ is ~ambiguous~, return ~ambiguous~.
1. If _resolution_ is not *null*, then
1. Assert: _resolution_ is a ResolvedBinding Record.
1. If _starResolution_ is *null*, set _starResolution_ to _resolution_.
1. Else,
1. Assert: There is more than one `*` import that includes the requested name.
1. If _resolution_.[[Module]] and _starResolution_.[[Module]] are not the same Module Record or SameValue(_resolution_.[[BindingName]], _starResolution_.[[BindingName]]) is *false*, return *"ambiguous"*.
1. If _resolution_.[[Module]] and _starResolution_.[[Module]] are not the same Module Record, return ~ambiguous~.
1. If _resolution_.[[BindingName]] is ~namespace~ and _starResolution_.[[BindingName]] is not ~namespace~, or if _resolution_.[[BindingName]] is not ~namespace~ and _starResolution_.[[BindingName]] is ~namespace~, return ~ambiguous~.
1. If _resolution_.[[BindingName]] is a String, _starResolution_.[[BindingName]] is a String, and SameValue(_resolution_.[[BindingName]], _starResolution_.[[BindingName]]) is *false*, return ~ambiguous~.
1. Return _starResolution_.
</emu-alg>
</emu-clause>
Expand All @@ -27713,7 +27716,7 @@ <h1>InitializeEnvironment ( )</h1>
<emu-alg>
1. For each ExportEntry Record _e_ of _module_.[[IndirectExportEntries]], do
1. Let _resolution_ be ? _module_.ResolveExport(_e_.[[ExportName]]).
1. If _resolution_ is *null* or *"ambiguous"*, throw a *SyntaxError* exception.
1. If _resolution_ is *null* or ~ambiguous~, throw a *SyntaxError* exception.
1. Assert: _resolution_ is a ResolvedBinding Record.
1. Assert: All named exports from _module_ are resolvable.
1. Let _realm_ be _module_.[[Realm]].
Expand All @@ -27723,14 +27726,14 @@ <h1>InitializeEnvironment ( )</h1>
1. For each ImportEntry Record _in_ of _module_.[[ImportEntries]], do
1. Let _importedModule_ be ! HostResolveImportedModule(_module_, _in_.[[ModuleRequest]]).
1. NOTE: The above call cannot fail because imported module requests are a subset of _module_.[[RequestedModules]], and these have been resolved earlier in this algorithm.
1. If _in_.[[ImportName]] is *"\*"*, then
1. If _in_.[[ImportName]] is ~namespace-object~, then
1. Let _namespace_ be ? GetModuleNamespace(_importedModule_).
1. Perform ! _env_.CreateImmutableBinding(_in_.[[LocalName]], *true*).
1. Call _env_.InitializeBinding(_in_.[[LocalName]], _namespace_).
1. Else,
1. Let _resolution_ be ? _importedModule_.ResolveExport(_in_.[[ImportName]]).
1. If _resolution_ is *null* or *"ambiguous"*, throw a *SyntaxError* exception.
1. If _resolution_.[[BindingName]] is *"\*namespace\*"*, then
1. If _resolution_ is *null* or ~ambiguous~, throw a *SyntaxError* exception.
1. If _resolution_.[[BindingName]] is ~namespace~, then
1. Let _namespace_ be ? GetModuleNamespace(_resolution_.[[Module]]).
1. Perform ! _env_.CreateImmutableBinding(_in_.[[LocalName]], *true*).
1. Call _env_.InitializeBinding(_in_.[[LocalName]], _namespace_).
Expand Down Expand Up @@ -28101,7 +28104,7 @@ <h1>
<emu-grammar>NameSpaceImport : `*` `as` ImportedBinding</emu-grammar>
<emu-alg>
1. Let _localName_ be the StringValue of |ImportedBinding|.
1. Let _entry_ be the ImportEntry Record { [[ModuleRequest]]: _module_, [[ImportName]]: *"\*"*, [[LocalName]]: _localName_ }.
1. Let _entry_ be the ImportEntry Record { [[ModuleRequest]]: _module_, [[ImportName]]: ~namespace-object~, [[LocalName]]: _localName_ }.
1. Return a List whose sole element is _entry_.
</emu-alg>
<emu-grammar>NamedImports : `{` `}`</emu-grammar>
Expand Down Expand Up @@ -28387,7 +28390,7 @@ <h1>Static Semantics: ExportEntries</h1>
1. Return a List whose sole element is _entry_.
</emu-alg>
<emu-note>
<p>*"\*default\*"* is used within this specification as a synthetic name for anonymous default export values.</p>
<p>*"\*default\*"* is used within this specification as a synthetic name for anonymous default export values. See <emu-xref href="#note-star-default-star">this note</emu-xref> for more details.</p>
</emu-note>
</emu-clause>

Expand All @@ -28401,13 +28404,13 @@ <h1>
</dl>
<emu-grammar>ExportFromClause : `*`</emu-grammar>
<emu-alg>
1. Let _entry_ be the ExportEntry Record { [[ModuleRequest]]: _module_, [[ImportName]]: *"\*"*, [[LocalName]]: *null*, [[ExportName]]: *null* }.
1. Let _entry_ be the ExportEntry Record { [[ModuleRequest]]: _module_, [[ImportName]]: ~all-but-default~, [[LocalName]]: *null*, [[ExportName]]: *null* }.
1. Return a List whose sole element is _entry_.
</emu-alg>
<emu-grammar>ExportFromClause : `*` `as` IdentifierName</emu-grammar>
<emu-alg>
1. Let _exportName_ be the StringValue of |IdentifierName|.
1. Let _entry_ be the ExportEntry Record { [[ModuleRequest]]: _module_, [[ImportName]]: *"\*"*, [[LocalName]]: *null*, [[ExportName]]: _exportName_ }.
1. Let _entry_ be the ExportEntry Record { [[ModuleRequest]]: _module_, [[ImportName]]: ~all~, [[LocalName]]: *null*, [[ExportName]]: _exportName_ }.
1. Return a List whose sole element is _entry_.
</emu-alg>
<emu-grammar>NamedExports : `{` `}`</emu-grammar>
Expand Down