15 ECMAScript Language: Scripts and Modules
15.1 Scripts
Syntax
15.1.1 Static Semantics: Early Errors
-
It is a Syntax Error if the LexicallyDeclaredNames of
ScriptBody contains any duplicate entries. -
It is a Syntax Error if any element of the LexicallyDeclaredNames of
ScriptBody also occurs in the VarDeclaredNames ofScriptBody .
-
It is a Syntax Error if
StatementList Containssuperunless the source code containingsuperis eval code that is being processed by adirect eval . Additionalearly error rules forsuperwithindirect eval are defined in18.2.1.1 . -
It is a Syntax Error if
StatementList ContainsNewTarget unless the source code containingNewTarget is eval code that is being processed by adirect eval . Additionalearly error rules forNewTarget indirect eval are defined in18.2.1.1 . -
It is a Syntax Error if ContainsDuplicateLabels of
StatementList with argument « » istrue . -
It is a Syntax Error if ContainsUndefinedBreakTarget of
StatementList with argument « » istrue . -
It is a Syntax Error if ContainsUndefinedContinueTarget of
StatementList with arguments « » and « » istrue .
15.1.2 Static Semantics: IsStrict
- If
ScriptBody is present and theDirective Prologue ofScriptBody contains aUse Strict Directive , returntrue ; otherwise, returnfalse .
15.1.3 Static Semantics: LexicallyDeclaredNames
- Return TopLevelLexicallyDeclaredNames of
StatementList .
At the top level of a
15.1.4 Static Semantics: LexicallyScopedDeclarations
15.1.5 Static Semantics: VarDeclaredNames
15.1.6 Static Semantics: VarScopedDeclarations
15.1.7 Runtime Semantics: Evaluation
- Return
NormalCompletion (undefined ).
15.1.8 Script Records
A Script Record encapsulates information about a script being evaluated. Each script record contains the fields listed in
| Field Name |
Value |
Meaning |
|---|---|---|
| [[Realm]] |
|
The |
| [[Environment]] |
|
The |
| [[ECMAScriptCode]] |
a |
The result of parsing the source text of this script using |
| [[HostDefined]] |
Any, default value is |
Field reserved for use by host environments that need to associate additional information with a script. |
15.1.9 ParseScript ( sourceText, realm, hostDefined )
The abstract operation ParseScript with arguments sourceText, realm, and hostDefined creates a
Assert : sourceText is an ECMAScript source text (see clause10 ).- Parse sourceText using
Script as thegoal symbol and analyse the parse result for any Early Error conditions. If the parse was successful and no early errors were found, let body be the resulting parse tree. Otherwise, let body be aList of one or moreSyntaxError objects representing the parsing errors and/or early errors. Parsing andearly error detection may be interweaved in an implementation-dependent manner. If more than one parsing error orearly error is present, the number and ordering of error objects in the list is implementation-dependent, but at least one must be present. - If body is a
List of errors, return body. - Return
Script Record { [[Realm]]: realm, [[Environment]]:undefined , [[ECMAScriptCode]]: body, [[HostDefined]]: hostDefined }.
An implementation may parse script source text and analyse it for Early Error conditions prior to evaluation of ParseScript for that script source text. However, the reporting of any errors must be deferred until the point where this specification actually performs ParseScript upon that source text.
15.1.10 ScriptEvaluation ( scriptRecord )
- Let globalEnv be scriptRecord.[[Realm]].[[GlobalEnv]].
- Let scriptContext be a new ECMAScript code
execution context . Set the Function of scriptContext tonull .Set theRealm of scriptContext to scriptRecord.[[Realm]].Set the ScriptOrModule of scriptContext to scriptRecord.Set the VariableEnvironment of scriptContext to globalEnv.Set the LexicalEnvironment of scriptContext to globalEnv.Suspend the currentlyrunning execution context .- Push scriptContext onto the
execution context stack ; scriptContext is now therunning execution context . - Let scriptBody be scriptRecord.[[ECMAScriptCode]].
- Let result be
GlobalDeclarationInstantiation (scriptBody, globalEnv). - If result.[[Type]] is
normal , thenSet result to the result of evaluating scriptBody.
- If result.[[Type]] is
normal and result.[[Value]] isempty , thenSet result toNormalCompletion (undefined ).
Suspend scriptContext and remove it from theexecution context stack .Assert : Theexecution context stack is not empty.- Resume the context that is now on the top of the
execution context stack as therunning execution context . - Return
Completion (result).
15.1.11 Runtime Semantics: GlobalDeclarationInstantiation ( script, env )
When an
GlobalDeclarationInstantiation is performed as follows using arguments script and env. script is the
- Let envRec be env's
EnvironmentRecord . Assert : envRec is a globalEnvironment Record .- Let lexNames be the LexicallyDeclaredNames of script.
- Let varNames be the VarDeclaredNames of script.
- For each name in lexNames, do
- If envRec.HasVarDeclaration(name) is
true , throw aSyntaxError exception. - If envRec.HasLexicalDeclaration(name) is
true , throw aSyntaxError exception. - Let hasRestrictedGlobal be ? envRec.HasRestrictedGlobalProperty(name).
- If hasRestrictedGlobal is
true , throw aSyntaxError exception.
- If envRec.HasVarDeclaration(name) is
- For each name in varNames, do
- If envRec.HasLexicalDeclaration(name) is
true , throw aSyntaxError exception.
- If envRec.HasLexicalDeclaration(name) is
- Let varDeclarations be the VarScopedDeclarations of script.
- Let functionsToInitialize be a new empty
List . - Let declaredFunctionNames be a new empty
List . - For each d in varDeclarations, in reverse list order, do
- If d is neither a
VariableDeclaration nor aForBinding nor aBindingIdentifier , thenAssert : d is either aFunctionDeclaration , aGeneratorDeclaration , anAsyncFunctionDeclaration , or anAsyncGeneratorDeclaration .- NOTE: If there are multiple function declarations for the same name, the last declaration is used.
- Let fn be the sole element of the BoundNames of d.
- If fn is not an element of declaredFunctionNames, then
- Let fnDefinable be ? envRec.CanDeclareGlobalFunction(fn).
- If fnDefinable is
false , throw aTypeError exception. - Append fn to declaredFunctionNames.
- Insert d as the first element of functionsToInitialize.
- If d is neither a
- Let declaredVarNames be a new empty
List . - For each d in varDeclarations, do
- If d is a
VariableDeclaration , aForBinding , or aBindingIdentifier , then- For each String vn in the BoundNames of d, do
- If vn is not an element of declaredFunctionNames, then
- Let vnDefinable be ? envRec.CanDeclareGlobalVar(vn).
- If vnDefinable is
false , throw aTypeError exception. - If vn is not an element of declaredVarNames, then
- Append vn to declaredVarNames.
- If vn is not an element of declaredFunctionNames, then
- For each String vn in the BoundNames of d, do
- If d is a
- NOTE: No abnormal terminations occur after this algorithm step if the
global object is anordinary object . However, if theglobal object is aProxy exotic object it may exhibit behaviours that cause abnormal terminations in some of the following steps. - NOTE: Annex
B.3.3.2 adds additional steps at this point. - Let lexDeclarations be the LexicallyScopedDeclarations of script.
- For each element d in lexDeclarations, do
- NOTE: Lexically declared names are only instantiated here but not initialized.
- For each element dn of the BoundNames of d, do
- If IsConstantDeclaration of d is
true , then- Perform ? envRec.CreateImmutableBinding(dn,
true ).
- Perform ? envRec.CreateImmutableBinding(dn,
- Else,
- Perform ? envRec.CreateMutableBinding(dn,
false ).
- Perform ? envRec.CreateMutableBinding(dn,
- If IsConstantDeclaration of d is
- For each
Parse Node f in functionsToInitialize, do- Let fn be the sole element of the BoundNames of f.
- Let fo be InstantiateFunctionObject of f with argument env.
- Perform ? envRec.CreateGlobalFunctionBinding(fn, fo,
false ).
- For each String vn in declaredVarNames, in list order, do
- Perform ? envRec.CreateGlobalVarBinding(vn,
false ).
- Perform ? envRec.CreateGlobalVarBinding(vn,
- Return
NormalCompletion (empty ).
Early errors specified in
Unlike explicit var or function declarations, properties that are directly created on the
15.2 Modules
Syntax
15.2.1 Module Semantics
15.2.1.1 Static Semantics: Early Errors
-
It is a Syntax Error if the LexicallyDeclaredNames of
ModuleItemList contains any duplicate entries. -
It is a Syntax Error if any element of the LexicallyDeclaredNames of
ModuleItemList also occurs in the VarDeclaredNames ofModuleItemList . -
It is a Syntax Error if the ExportedNames of
ModuleItemList contains any duplicate entries. -
It is a Syntax Error if any element of the ExportedBindings of
ModuleItemList does not also occur in either the VarDeclaredNames ofModuleItemList , or the LexicallyDeclaredNames ofModuleItemList . -
It is a Syntax Error if
ModuleItemList Containssuper. -
It is a Syntax Error if
ModuleItemList ContainsNewTarget . -
It is a Syntax Error if ContainsDuplicateLabels of
ModuleItemList with argument « » istrue . -
It is a Syntax Error if ContainsUndefinedBreakTarget of
ModuleItemList with argument « » istrue . -
It is a Syntax Error if ContainsUndefinedContinueTarget of
ModuleItemList with arguments « » and « » istrue .
The duplicate ExportedNames rule implies that multiple export default
15.2.1.2 Static Semantics: ContainsDuplicateLabels
With parameter labelSet.
- Let hasDuplicates be ContainsDuplicateLabels of
ModuleItemList with argument labelSet. - If hasDuplicates is
true , returntrue . - Return ContainsDuplicateLabels of
ModuleItem with argument labelSet.
- Return
false .
15.2.1.3 Static Semantics: ContainsUndefinedBreakTarget
With parameter labelSet.
- Let hasUndefinedLabels be ContainsUndefinedBreakTarget of
ModuleItemList with argument labelSet. - If hasUndefinedLabels is
true , returntrue . - Return ContainsUndefinedBreakTarget of
ModuleItem with argument labelSet.
- Return
false .
15.2.1.4 Static Semantics: ContainsUndefinedContinueTarget
With parameters iterationSet and labelSet.
- Let hasUndefinedLabels be ContainsUndefinedContinueTarget of
ModuleItemList with arguments iterationSet and « ». - If hasUndefinedLabels is
true , returntrue . - Return ContainsUndefinedContinueTarget of
ModuleItem with arguments iterationSet and « ».
- Return
false .
15.2.1.5 Static Semantics: ExportedBindings
ExportedBindings are the locally bound names that are explicitly associated with a
- Let names be ExportedBindings of
ModuleItemList . - Append to names the elements of the ExportedBindings of
ModuleItem . - Return names.
- Return a new empty
List .
15.2.1.6 Static Semantics: ExportedNames
ExportedNames are the externally visible names that a
- Let names be ExportedNames of
ModuleItemList . - Append to names the elements of the ExportedNames of
ModuleItem . - Return names.
- Return the ExportedNames of
ExportDeclaration .
- Return a new empty
List .
15.2.1.7 Static Semantics: ExportEntries
- Return a new empty
List .
- Let entries be ExportEntries of
ModuleItemList . - Append to entries the elements of the ExportEntries of
ModuleItem . - Return entries.
- Return a new empty
List .
15.2.1.8 Static Semantics: ImportEntries
- Return a new empty
List .
- Let entries be ImportEntries of
ModuleItemList . - Append to entries the elements of the ImportEntries of
ModuleItem . - Return entries.
- Return a new empty
List .
15.2.1.9 Static Semantics: ImportedLocalNames ( importEntries )
The abstract operation ImportedLocalNames with argument importEntries creates a
- Let localNames be a new empty
List . - For each
ImportEntry Record i in importEntries, do- Append i.[[LocalName]] to localNames.
- Return localNames.
15.2.1.10 Static Semantics: ModuleRequests
- Return a new empty
List .
- Return ModuleRequests of
ModuleItem .
- Let moduleNames be ModuleRequests of
ModuleItemList . - Let additionalNames be ModuleRequests of
ModuleItem . - Append to moduleNames each element of additionalNames that is not already an element of moduleNames.
- Return moduleNames.
- Return a new empty
List .
15.2.1.11 Static Semantics: LexicallyDeclaredNames
The LexicallyDeclaredNames of a
- Let names be LexicallyDeclaredNames of
ModuleItemList . - Append to names the elements of the LexicallyDeclaredNames of
ModuleItem . - Return names.
- Return the BoundNames of
ImportDeclaration .
- If
ExportDeclaration isexportVariableStatement , return a new emptyList . - Return the BoundNames of
ExportDeclaration .
- Return LexicallyDeclaredNames of
StatementListItem .
At the top level of a
15.2.1.12 Static Semantics: LexicallyScopedDeclarations
- Return a new empty
List .
- Let declarations be LexicallyScopedDeclarations of
ModuleItemList . - Append to declarations the elements of the LexicallyScopedDeclarations of
ModuleItem . - Return declarations.
- Return a new empty
List .
15.2.1.13 Static Semantics: VarDeclaredNames
- Return a new empty
List .
- Let names be VarDeclaredNames of
ModuleItemList . - Append to names the elements of the VarDeclaredNames of
ModuleItem . - Return names.
- Return a new empty
List .
- If
ExportDeclaration isexportVariableStatement , return BoundNames ofExportDeclaration . - Return a new empty
List .
15.2.1.14 Static Semantics: VarScopedDeclarations
- Return a new empty
List .
- Let declarations be VarScopedDeclarations of
ModuleItemList . - Append to declarations the elements of the VarScopedDeclarations of
ModuleItem . - Return declarations.
- Return a new empty
List .
- If
ExportDeclaration isexportVariableStatement , return VarScopedDeclarations ofVariableStatement . - Return a new empty
List .
15.2.1.15 Abstract Module Records
A Module Record encapsulates structural information about the imports and exports of a single module. This information is used to link the imports and exports of sets of connected modules. A Module Record includes four fields that are only used when evaluating a module.
For specification purposes Module Record values are values of the
Module Record defines the fields listed in
| Field Name |
Value |
Meaning |
|---|---|---|
| [[Realm]] |
|
The |
| [[Environment]] |
|
The |
| [[Namespace]] |
Object | |
The Module Namespace Object ( |
| [[HostDefined]] |
Any, default value is |
Field reserved for use by host environments that need to associate additional information with a module. |
| Method | Purpose |
|---|---|
| GetExportedNames([exportStarSet]) | Return a list of all names that are either directly or indirectly exported from this module. |
| ResolveExport(exportName [, resolveSet]) |
Return the binding of a name exported by this module. Bindings are represented by a ResolvedBinding Record, 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 Each time this operation is called with a specific exportName, resolveSet pair as arguments it must return the same result if it completes normally. |
| Link() |
Prepare the module for evaluation by transitively resolving all module dependencies and creating a module |
| Evaluate() |
If this module has already been evaluated successfully, return Link must have completed successfully prior to invoking this method. |
15.2.1.16 Cyclic Module Records
A Cyclic Module Record is used to represent information about a module that can participate in dependency cycles with other modules that are subclasses of the
In addition to the fields defined in
| Field Name |
Value |
Meaning |
|---|---|---|
| [[Status]] |
|
Initially |
| [[EvaluationError]] |
An |
A completion of |
| [[DFSIndex]] |
|
Auxiliary field used during Link and Evaluate only.
If [[Status]] is |
| [[DFSAncestorIndex]] |
|
Auxiliary field used during Link and Evaluate only. If [[Status]] is |
| [[RequestedModules]] |
|
A |
In addition to the methods defined in
| Method | Purpose |
|---|---|
|
|
Initialize the |
|
|
Evaluate the module's code within its |
15.2.1.16.1 Link ( ) Concrete Method
The Link concrete method of a
On success, Link transitions this module's [[Status]] from
This abstract method performs the following steps (most of the work is done by the auxiliary function
- Let module be this
Cyclic Module Record . Assert : module.[[Status]] is notlinking orevaluating .- Let stack be a new empty
List . - Let result be
InnerModuleLinking (module, stack, 0). - If result is an
abrupt completion , then Assert : module.[[Status]] islinked orevaluated .Assert : stack is empty.- Return
undefined .
15.2.1.16.1.1 InnerModuleLinking ( module, stack, index )
The InnerModuleLinking abstract operation is used by Link to perform the actual linking process for the
This abstract operation performs the following steps:
- If module is not a
Cyclic Module Record , then- Perform ? module.Link().
- Return index.
- If module.[[Status]] is
linking ,linked , orevaluated , then- Return index.
Assert : module.[[Status]] isunlinked .Set module.[[Status]] tolinking .Set module.[[DFSIndex]] to index.Set module.[[DFSAncestorIndex]] to index.Set index to index + 1.- Append module to stack.
- For each String required that is an element of module.[[RequestedModules]], do
- Let requiredModule be ?
HostResolveImportedModule (module, required). Set index to ? InnerModuleLinking(requiredModule, stack, index).- If requiredModule is a
Cyclic Module Record , then
- Let requiredModule be ?
- Perform ? module.
InitializeEnvironment (). Assert : module occurs exactly once in stack.Assert : module.[[DFSAncestorIndex]] is less than or equal to module.[[DFSIndex]].- If module.[[DFSAncestorIndex]] equals module.[[DFSIndex]], then
- Let done be
false . - Repeat, while done is
false ,- Let requiredModule be the last element in stack.
- Remove the last element of stack.
Assert : requiredModule is aCyclic Module Record .Set requiredModule.[[Status]] tolinked .- If requiredModule and module are the same
Module Record , set done totrue .
- Let done be
- Return index.
15.2.1.16.2 Evaluate ( ) Concrete Method
The Evaluate concrete method of a
Evaluate transitions this module's [[Status]] from
If execution results in an exception, that exception is recorded in the [[EvaluationError]] field and rethrown by future invocations of Evaluate.
This abstract method performs the following steps (most of the work is done by the auxiliary function
Assert : This call to Evaluate is not happening at the same time as another call to Evaluate within thesurrounding agent .- Let module be this
Cyclic Module Record . Assert : module.[[Status]] islinked orevaluated .- Let stack be a new empty
List . - Let result be
InnerModuleEvaluation (module, stack, 0). - If result is an
abrupt completion , then- For each
Cyclic Module Record m in stack, do Assert : module.[[Status]] isevaluated and module.[[EvaluationError]] is result.- Return result.
- For each
Assert : module.[[Status]] isevaluated and module.[[EvaluationError]] isundefined .Assert : stack is empty.- Return
undefined .
15.2.1.16.2.1 InnerModuleEvaluation ( module, stack, index )
The InnerModuleEvaluation abstract operation is used by Evaluate to perform the actual evaluation process for the
This abstract operation performs the following steps:
- If module is not a
Cyclic Module Record , then- Perform ? module.Evaluate().
- Return index.
- If module.[[Status]] is
evaluated , then- If module.[[EvaluationError]] is
undefined , return index. - Otherwise, return module.[[EvaluationError]].
- If module.[[EvaluationError]] is
- If module.[[Status]] is
evaluating , return index. Assert : module.[[Status]] islinked .Set module.[[Status]] toevaluating .Set module.[[DFSIndex]] to index.Set module.[[DFSAncestorIndex]] to index.Set index to index + 1.- Append module to stack.
- For each String required that is an element of module.[[RequestedModules]], do
- Let requiredModule be !
HostResolveImportedModule (module, required). - NOTE: Link must be completed successfully prior to invoking this method, so every requested module is guaranteed to resolve successfully.
Set index to ? InnerModuleEvaluation(requiredModule, stack, index).- If requiredModule is a
Cyclic Module Record , then
- Let requiredModule be !
- Perform ? module.
ExecuteModule (). Assert : module occurs exactly once in stack.Assert : module.[[DFSAncestorIndex]] is less than or equal to module.[[DFSIndex]].- If module.[[DFSAncestorIndex]] equals module.[[DFSIndex]], then
- Let done be
false . - Repeat, while done is
false ,- Let requiredModule be the last element in stack.
- Remove the last element of stack.
Assert : requiredModule is aCyclic Module Record .Set requiredModule.[[Status]] toevaluated .- If requiredModule and module are the same
Module Record , set done totrue .
- Let done be
- Return index.
15.2.1.16.3 Example Cyclic Module Record Graphs
This non-normative section gives a series of examples of the linking and evaluation of a few common module graphs, with a specific focus on how errors can occur.
First consider the following simple module graph:
Let's first assume that there are no error conditions. When a host first calls A.Link(), this will complete successfully by assumption, and recursively link modules B and C as well, such that A.[[Status]] = B.[[Status]] = C.[[Status]] =
Consider then cases involving linking errors. If
Finally, consider a case involving evaluation errors. If
The difference here between linking and evaluation errors is due to how evaluation must be only performed once, as it can cause side effects; it is thus important to remember whether evaluation has already been performed, even if unsuccessfully. (In the error case, it makes sense to also remember the exception because otherwise subsequent Evaluate() calls would have to synthesize a new one.) Linking, on the other hand, is side-effect-free, and thus even if it fails, it can be retried at a later time with no issues.
Now consider a different
In this scenario, module A declares a dependency on some other module, but no
Lastly, consider a module graph with a cycle:
Here we assume that the entry point is module A, so that the host proceeds by calling A.Link(), which performs
An analogous story occurs for the evaluation phase of a cyclic module graph, in the success case.
Now consider a case where A has an linking error; for example, it tries to import a binding from C that does not exist. In that case, the above steps still occur, including the early return from the second call to
Finally, consider a case where A has an evaluation error; for example, its source code throws an exception. In that case, the evaluation-time analog of the above steps still occurs, including the early return from the second call to
15.2.1.17 Source Text Module Records
A Source Text Module Record is used to represent information about a module that was defined from ECMAScript source text (
A
In addition to the fields defined in
| Field Name |
Value |
Meaning |
|---|---|---|
| [[ECMAScriptCode]] |
a |
The result of parsing the source text of this module using |
| [[Context]] |
An ECMAScript |
The |
| [[ImportMeta]] | Object |
An object exposed through the import.meta meta property. It is |
| [[ImportEntries]] |
|
A |
| [[LocalExportEntries]] |
|
A |
| [[IndirectExportEntries]] |
|
A export * as namespace declarations.
|
| [[StarExportEntries]] |
|
A export * declarations that occur within the module, not including export * as namespace declarations.
|
An ImportEntry Record is a
| Field Name |
Value |
Meaning |
|---|---|---|
| [[ModuleRequest]] | String |
String value of the |
| [[ImportName]] | String |
The name under which the desired binding is exported by the module identified by [[ModuleRequest]]. The value |
| [[LocalName]] | String | The name that is used to locally access the imported value from within the importing module. |
| Import Statement Form | [[ModuleRequest]] | [[ImportName]] | [[LocalName]] |
|---|---|---|---|
import v from "mod";
|
|
|
|
import * as ns from "mod";
|
|
|
|
import {x} from "mod";
|
|
|
|
import {x as v} from "mod";
|
|
|
|
import "mod";
|
An |
||
An ExportEntry Record is a
| Field Name |
Value |
Meaning |
|---|---|---|
| [[ExportName]] | String | null | The name used to export this binding by this module. |
| [[ModuleRequest]] | String | null |
The String value of the |
| [[ImportName]] | String | null |
The name under which the desired binding is exported by the module identified by [[ModuleRequest]]. |
| [[LocalName]] | String | null |
The name that is used to locally access the exported value from within the importing module. |
| Export Statement Form | [[ExportName]] | [[ModuleRequest]] | [[ImportName]] | [[LocalName]] |
|---|---|---|---|---|
export var v;
|
|
|
|
|
export default function f() {}
|
|
|
|
|
export default function () {}
|
|
|
|
|
export default 42;
|
|
|
|
|
export {x};
|
|
|
|
|
export {v as x};
|
|
|
|
|
export {x} from "mod";
|
|
|
|
|
export {v as x} from "mod";
|
|
|
|
|
export * from "mod";
|
|
|
|
|
export * as ns from "mod";
|
|
|
|
|
The following definitions specify the required concrete methods and other
15.2.1.17.1 ParseModule ( sourceText, realm, hostDefined )
The abstract operation ParseModule with arguments sourceText, realm, and hostDefined creates a
Assert : sourceText is an ECMAScript source text (see clause10 ).- Parse sourceText using
Module as thegoal symbol and analyse the parse result for any Early Error conditions. If the parse was successful and no early errors were found, let body be the resulting parse tree. Otherwise, let body be aList of one or moreSyntaxError objects representing the parsing errors and/or early errors. Parsing andearly error detection may be interweaved in an implementation-dependent manner. If more than one parsing error orearly error is present, the number and ordering of error objects in the list is implementation-dependent, but at least one must be present. - If body is a
List of errors, return body. - Let requestedModules be the ModuleRequests of body.
- Let importEntries be ImportEntries of body.
- Let importedBoundNames be
ImportedLocalNames (importEntries). - Let indirectExportEntries be a new empty
List . - Let localExportEntries be a new empty
List . - Let starExportEntries be a new empty
List . - Let exportEntries be ExportEntries of body.
- For each
ExportEntry Record ee in exportEntries, do- If ee.[[ModuleRequest]] is
null , then- If ee.[[LocalName]] is not an element of importedBoundNames, then
- Append ee to localExportEntries.
- Else,
- Let ie be the element of importEntries whose [[LocalName]] is the same as ee.[[LocalName]].
- If ie.[[ImportName]] is
"*" , then- NOTE: This is a re-export of an imported module namespace object.
- Append ee to localExportEntries.
- Else,
- NOTE: This is a re-export of a single name.
- Append the
ExportEntry Record { [[ModuleRequest]]: ie.[[ModuleRequest]], [[ImportName]]: ie.[[ImportName]], [[LocalName]]:null , [[ExportName]]: ee.[[ExportName]] } to indirectExportEntries.
- If ee.[[LocalName]] is not an element of importedBoundNames, then
- Else if ee.[[ImportName]] is
"*" and ee.[[ExportName]] isnull , then- Append ee to starExportEntries.
- Else,
- Append ee to indirectExportEntries.
- If ee.[[ModuleRequest]] is
- Return
Source Text Module Record { [[Realm]]: realm, [[Environment]]:undefined , [[Namespace]]:undefined , [[Status]]:unlinked , [[EvaluationError]]:undefined , [[HostDefined]]: hostDefined, [[ECMAScriptCode]]: body, [[Context]]:empty , [[ImportMeta]]:empty , [[RequestedModules]]: requestedModules, [[ImportEntries]]: importEntries, [[LocalExportEntries]]: localExportEntries, [[IndirectExportEntries]]: indirectExportEntries, [[StarExportEntries]]: starExportEntries, [[DFSIndex]]:undefined , [[DFSAncestorIndex]]:undefined }.
An implementation may parse module source text and analyse it for Early Error conditions prior to the evaluation of ParseModule for that module source text. However, the reporting of any errors must be deferred until the point where this specification actually performs ParseModule upon that source text.
15.2.1.17.2 GetExportedNames ( [ exportStarSet ] ) Concrete Method
The GetExportedNames concrete method of a
It performs the following steps:
- If exportStarSet is not present, set exportStarSet to a new empty
List . Assert : exportStarSet is aList of Source Text Module Records.- Let module be this
Source Text Module Record . - If exportStarSet contains module, then
- Append module to exportStarSet.
- Let exportedNames be a new empty
List . - For each
ExportEntry Record e in module.[[LocalExportEntries]], doAssert : module provides the direct binding for this export.- Append e.[[ExportName]] to exportedNames.
- For each
ExportEntry Record e in module.[[IndirectExportEntries]], doAssert : module imports a specific binding for this export.- Append e.[[ExportName]] to exportedNames.
- For each
ExportEntry Record e in module.[[StarExportEntries]], do- Let requestedModule be ?
HostResolveImportedModule (module, e.[[ModuleRequest]]). - Let starNames be ? requestedModule.GetExportedNames(exportStarSet).
- For each element n of starNames, do
- If
SameValue (n,"default" ) isfalse , then- If n is not an element of exportedNames, then
- Append n to exportedNames.
- If n is not an element of exportedNames, then
- If
- Let requestedModule be ?
- Return exportedNames.
GetExportedNames does not filter out or throw an exception for names that have ambiguous star export bindings.
15.2.1.17.3 ResolveExport ( exportName [ , resolveSet ] ) Concrete Method
The ResolveExport concrete method of a
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
If a defining module is found, a
This abstract method performs the following steps:
- If resolveSet is not present, set resolveSet to a new empty
List . Assert : resolveSet is aList ofRecord { [[Module]], [[ExportName]] }.- Let module be this
Source Text Module Record . - For each
Record { [[Module]], [[ExportName]] } r in resolveSet, do- If module and r.[[Module]] are the same
Module Record andSameValue (exportName, r.[[ExportName]]) istrue , thenAssert : This is a circular import request.- Return
null .
- If module and r.[[Module]] are the same
- Append the
Record { [[Module]]: module, [[ExportName]]: exportName } to resolveSet. - For each
ExportEntry Record e in module.[[LocalExportEntries]], do- If
SameValue (exportName, e.[[ExportName]]) istrue , thenAssert : module provides the direct binding for this export.- Return
ResolvedBinding Record { [[Module]]: module, [[BindingName]]: e.[[LocalName]] }.
- If
- For each
ExportEntry Record e in module.[[IndirectExportEntries]], do- If
SameValue (exportName, e.[[ExportName]]) istrue , then- Let importedModule be ?
HostResolveImportedModule (module, e.[[ModuleRequest]]). - If e.[[ImportName]] is
"*" , thenAssert : module does not provide the direct binding for this export.- Return
ResolvedBinding Record { [[Module]]: importedModule, [[BindingName]]:"*namespace*" }.
- Else,
Assert : module imports a specific binding for this export.- Return importedModule.ResolveExport(e.[[ImportName]], resolveSet).
- Let importedModule be ?
- If
- If
SameValue (exportName,"default" ) istrue , thenAssert : Adefaultexport was not explicitly defined by this module.- Return
null . - NOTE: A
defaultexport cannot be provided by anexport *orexport * from "mod"declaration.
- Let starResolution be
null . - For each
ExportEntry Record e in module.[[StarExportEntries]], do- Let importedModule be ?
HostResolveImportedModule (module, e.[[ModuleRequest]]). - Let resolution be ? importedModule.ResolveExport(exportName, resolveSet).
- If resolution is
"ambiguous" , return"ambiguous" . - If resolution is not
null , thenAssert : resolution is aResolvedBinding Record .- If starResolution is
null , set starResolution to resolution. - Else,
Assert : There is more than one*import that includes the requested name.- If resolution.[[Module]] and starResolution.[[Module]] are not the same
Module Record orSameValue (resolution.[[BindingName]], starResolution.[[BindingName]]) isfalse , return"ambiguous" .
- Let importedModule be ?
- Return starResolution.
15.2.1.17.4 InitializeEnvironment ( ) Concrete Method
The InitializeEnvironment concrete method of a
This abstract method performs the following steps:
- Let module be this
Source Text Module Record . - For each
ExportEntry Record e in module.[[IndirectExportEntries]], do- Let resolution be ? module.ResolveExport(e.[[ExportName]]).
- If resolution is
null or"ambiguous" , throw aSyntaxError exception. Assert : resolution is aResolvedBinding Record .
Assert : All named exports from module are resolvable.- Let realm be module.[[Realm]].
Assert : realm is notundefined .- Let env be
NewModuleEnvironment (realm.[[GlobalEnv]]). Set module.[[Environment]] to env.- Let envRec be env's
EnvironmentRecord . - For each
ImportEntry Record in in module.[[ImportEntries]], do- Let importedModule be !
HostResolveImportedModule (module, in.[[ModuleRequest]]). - 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.
- If in.[[ImportName]] is
"*" , then- Let namespace be ?
GetModuleNamespace (importedModule). - Perform ! envRec.CreateImmutableBinding(in.[[LocalName]],
true ). - Call envRec.InitializeBinding(in.[[LocalName]], namespace).
- Let namespace be ?
- Else,
- Let resolution be ? importedModule.ResolveExport(in.[[ImportName]]).
- If resolution is
null or"ambiguous" , throw aSyntaxError exception. - If resolution.[[BindingName]] is
"*namespace*" , then- Let namespace be ?
GetModuleNamespace (resolution.[[Module]]). - Perform ! envRec.CreateImmutableBinding(in.[[LocalName]],
true ). - Call envRec.InitializeBinding(in.[[LocalName]], namespace).
- Let namespace be ?
- Else,
- Call envRec.CreateImportBinding(in.[[LocalName]], resolution.[[Module]], resolution.[[BindingName]]).
- Let importedModule be !
- Let moduleContext be a new ECMAScript code
execution context . Set the Function of moduleContext tonull .Assert : module.[[Realm]] is notundefined .Set theRealm of moduleContext to module.[[Realm]].Set the ScriptOrModule of moduleContext to module.Set the VariableEnvironment of moduleContext to module.[[Environment]].Set the LexicalEnvironment of moduleContext to module.[[Environment]].Set module.[[Context]] to moduleContext.- Push moduleContext onto the
execution context stack ; moduleContext is now therunning execution context . - Let code be module.[[ECMAScriptCode]].
- Let varDeclarations be the VarScopedDeclarations of code.
- Let declaredVarNames be a new empty
List . - For each element d in varDeclarations, do
- For each element dn of the BoundNames of d, do
- If dn is not an element of declaredVarNames, then
- Perform ! envRec.CreateMutableBinding(dn,
false ). - Call envRec.InitializeBinding(dn,
undefined ). - Append dn to declaredVarNames.
- Perform ! envRec.CreateMutableBinding(dn,
- If dn is not an element of declaredVarNames, then
- For each element dn of the BoundNames of d, do
- Let lexDeclarations be the LexicallyScopedDeclarations of code.
- For each element d in lexDeclarations, do
- For each element dn of the BoundNames of d, do
- If IsConstantDeclaration of d is
true , then- Perform ! envRec.CreateImmutableBinding(dn,
true ).
- Perform ! envRec.CreateImmutableBinding(dn,
- Else,
- Perform ! envRec.CreateMutableBinding(dn,
false ).
- Perform ! envRec.CreateMutableBinding(dn,
- If d is a
FunctionDeclaration , aGeneratorDeclaration , anAsyncFunctionDeclaration , or anAsyncGeneratorDeclaration , then- Let fo be InstantiateFunctionObject of d with argument env.
- Call envRec.InitializeBinding(dn, fo).
- If IsConstantDeclaration of d is
- For each element dn of the BoundNames of d, do
- Remove moduleContext from the
execution context stack . - Return
NormalCompletion (empty ).
15.2.1.17.5 ExecuteModule ( ) Concrete Method
The ExecuteModule concrete method of a
This abstract method performs the following steps:
- Let module be this
Source Text Module Record . Suspend the currentlyrunning execution context .- Let moduleContext be module.[[Context]].
- Push moduleContext onto the
execution context stack ; moduleContext is now therunning execution context . - Let result be the result of evaluating module.[[ECMAScriptCode]].
Suspend moduleContext and remove it from theexecution context stack .- Resume the context that is now on the top of the
execution context stack as therunning execution context . - Return
Completion (result).
15.2.1.18 Runtime Semantics: HostResolveImportedModule ( referencingScriptOrModule, specifier )
HostResolveImportedModule is an implementation-defined abstract operation that provides the concrete import()
An example of when referencingScriptOrModule can be
<button type="button" onclick="import('./foo.mjs')">Click me</button>
there will be no active script or module at the time the import()
The implementation of HostResolveImportedModule must conform to the following requirements:
-
The normal return value must be an instance of a concrete subclass of
Module Record . -
If a
Module Record corresponding to the pair referencingScriptOrModule, specifier does not exist or cannot be created, an exception must be thrown. -
Each time this operation is called with a specific referencingScriptOrModule, specifier pair as arguments it must return the same
Module Record instance if it completes normally.
Multiple different referencingScriptOrModule, specifier pairs may map to the same
15.2.1.19 Runtime Semantics: HostImportModuleDynamically ( referencingScriptOrModule, specifier, promiseCapability )
HostImportModuleDynamically is an implementation-defined abstract operation that performs any necessary setup work in order to make available the module corresponding to the import()
The implementation of HostImportModuleDynamically must conform to the following requirements:
-
The abstract operation must always complete normally with
undefined . Success or failure must instead be signaled as discussed below. -
The host environment must conform to one of the two following sets of requirements:
- Success path
-
- At some future time, the host environment must perform
FinishDynamicImport (referencingScriptOrModule, specifier, promiseCapability,NormalCompletion (undefined )). - Any subsequent call to
HostResolveImportedModule afterFinishDynamicImport has completed, given the arguments referencingScriptOrModule and specifier, must complete normally. - The completion value of any subsequent call to
HostResolveImportedModule afterFinishDynamicImport has completed, given the arguments referencingScriptOrModule and specifier, must be a module which has already been evaluated, i.e. whose Evaluate concrete method has already been called and returned a normal completion.
- At some future time, the host environment must perform
- Failure path
-
- At some future time, the host environment must perform
FinishDynamicImport (referencingScriptOrModule, specifier, promiseCapability, anabrupt completion ), with theabrupt completion representing the cause of failure.
- At some future time, the host environment must perform
- If the host environment takes the success path once for a given referencingScriptOrModule, specifier pair, it must always do so for subsequent calls.
-
The operation must not call promiseCapability.[[Resolve]] or promiseCapability.[[Reject]], but instead must treat promiseCapability as an opaque identifying value to be passed through to
FinishDynamicImport .
The actual process performed is implementation-defined, but typically consists of performing whatever I/O operations are necessary to allow
15.2.1.20 Runtime Semantics: FinishDynamicImport ( referencingScriptOrModule, specifier, promiseCapability, completion )
FinishDynamicImport completes the process of a dynamic import originally started by an import()
- If completion is an
abrupt completion , then perform !Call (promiseCapability.[[Reject]],undefined , « completion.[[Value]] »). - Else,
Assert : completion is a normal completion and completion.[[Value]] isundefined .- Let moduleRecord be !
HostResolveImportedModule (referencingScriptOrModule, specifier). Assert : Evaluate has already been invoked on moduleRecord and successfully completed.- Let namespace be
GetModuleNamespace (moduleRecord). - If namespace is an
abrupt completion , perform !Call (promiseCapability.[[Reject]],undefined , « namespace.[[Value]] »). - Else, perform !
Call (promiseCapability.[[Resolve]],undefined , « namespace.[[Value]] »).
15.2.1.21 Runtime Semantics: GetModuleNamespace ( module )
The GetModuleNamespace abstract operation retrieves the Module Namespace Object representing module's exports, lazily creating it the first time it was requested, and storing it in module.[[Namespace]] for future retrieval.
This abstract operation performs the following steps:
Assert : module is an instance of a concrete subclass ofModule Record .Assert : If module is aCyclic Module Record , then module.[[Status]] is notunlinked .- Let namespace be module.[[Namespace]].
- If namespace is
undefined , then- Let exportedNames be ? module.GetExportedNames().
- Let unambiguousNames be a new empty
List . - For each name that is an element of exportedNames, do
- Let resolution be ? module.ResolveExport(name).
- If resolution is a
ResolvedBinding Record , append name to unambiguousNames.
Set namespace toModuleNamespaceCreate (module, unambiguousNames).
- Return namespace.
The only way GetModuleNamespace can throw is via one of the triggered
15.2.1.22 Runtime Semantics: Evaluation
- Return
NormalCompletion (undefined ).
- Let result be the result of evaluating
ModuleItemList . - If result.[[Type]] is
normal and result.[[Value]] isempty , then- Return
NormalCompletion (undefined ).
- Return
- Return
Completion (result).
- Let sl be the result of evaluating
ModuleItemList . ReturnIfAbrupt (sl).- Let s be the result of evaluating
ModuleItem . - Return
Completion (UpdateEmpty (s, sl)).
The value of a
- Return
NormalCompletion (empty ).
15.2.2 Imports
Syntax
15.2.2.1 Static Semantics: Early Errors
-
It is a Syntax Error if the BoundNames of
ImportDeclaration contains any duplicate entries.
15.2.2.2 Static Semantics: BoundNames
- Return the BoundNames of
ImportClause .
- Return a new empty
List .
- Let names be the BoundNames of
ImportedDefaultBinding . - Append to names the elements of the BoundNames of
NameSpaceImport . - Return names.
- Let names be the BoundNames of
ImportedDefaultBinding . - Append to names the elements of the BoundNames of
NamedImports . - Return names.
- Return a new empty
List .
- Let names be the BoundNames of
ImportsList . - Append to names the elements of the BoundNames of
ImportSpecifier . - Return names.
- Return the BoundNames of
ImportedBinding .
15.2.2.3 Static Semantics: ImportEntries
- Let module be the sole element of ModuleRequests of
FromClause . - Return ImportEntriesForModule of
ImportClause with argument module.
- Return a new empty
List .
15.2.2.4 Static Semantics: ImportEntriesForModule
With parameter module.
- Let entries be ImportEntriesForModule of
ImportedDefaultBinding with argument module. - Append to entries the elements of the ImportEntriesForModule of
NameSpaceImport with argument module. - Return entries.
- Let entries be ImportEntriesForModule of
ImportedDefaultBinding with argument module. - Append to entries the elements of the ImportEntriesForModule of
NamedImports with argument module. - Return entries.
- Let localName be the sole element of BoundNames of
ImportedBinding . - Let defaultEntry be the
ImportEntry Record { [[ModuleRequest]]: module, [[ImportName]]:"default" , [[LocalName]]: localName }. - Return a new
List containing defaultEntry.
- Let localName be the StringValue of
ImportedBinding . - Let entry be the
ImportEntry Record { [[ModuleRequest]]: module, [[ImportName]]:"*" , [[LocalName]]: localName }. - Return a new
List containing entry.
- Return a new empty
List .
- Let specs be the ImportEntriesForModule of
ImportsList with argument module. - Append to specs the elements of the ImportEntriesForModule of
ImportSpecifier with argument module. - Return specs.
- Let localName be the sole element of BoundNames of
ImportedBinding . - Let entry be the
ImportEntry Record { [[ModuleRequest]]: module, [[ImportName]]: localName, [[LocalName]]: localName }. - Return a new
List containing entry.
- Let importName be the StringValue of
IdentifierName . - Let localName be the StringValue of
ImportedBinding . - Let entry be the
ImportEntry Record { [[ModuleRequest]]: module, [[ImportName]]: importName, [[LocalName]]: localName }. - Return a new
List containing entry.
15.2.2.5 Static Semantics: ModuleRequests
- Return ModuleRequests of
FromClause .
- Return a
List containing the StringValue ofStringLiteral .
15.2.3 Exports
Syntax
15.2.3.1 Static Semantics: Early Errors
-
For each
IdentifierName n in ReferencedBindings ofNamedExports : It is a Syntax Error if StringValue of n is aReservedWord or if the StringValue of n is one of:"implements" ,"interface" ,"let" ,"package" ,"private" ,"protected" ,"public" , or"static" .
The above rule means that each ReferencedBindings of
15.2.3.2 Static Semantics: BoundNames
- Return a new empty
List .
- Return the BoundNames of
VariableStatement .
- Return the BoundNames of
Declaration .
- Let declarationNames be the BoundNames of
HoistableDeclaration . - If declarationNames does not include the element
"*default*" , append"*default*" to declarationNames. - Return declarationNames.
- Let declarationNames be the BoundNames of
ClassDeclaration . - If declarationNames does not include the element
"*default*" , append"*default*" to declarationNames. - Return declarationNames.
- Return «
"*default*" ».
15.2.3.3 Static Semantics: ExportedBindings
- Return a new empty
List .
- Return the ExportedBindings of
NamedExports .
- Return the BoundNames of
VariableStatement .
- Return the BoundNames of
Declaration .
- Return the BoundNames of this
ExportDeclaration .
- Return a new empty
List .
- Let names be the ExportedBindings of
ExportsList . - Append to names the elements of the ExportedBindings of
ExportSpecifier . - Return names.
- Return a
List containing the StringValue ofIdentifierName .
- Return a
List containing the StringValue of the firstIdentifierName .
15.2.3.4 Static Semantics: ExportedNames
- Return the ExportedNames of
ExportFromClause .
- Return a new empty
List .
- Return a
List containing the StringValue ofIdentifierName .
- Return the ExportedNames of
NamedExports .
- Return the BoundNames of
VariableStatement .
- Return the BoundNames of
Declaration .
- Return «
"default" ».
- Return a new empty
List .
- Let names be the ExportedNames of
ExportsList . - Append to names the elements of the ExportedNames of
ExportSpecifier . - Return names.
- Return a
List containing the StringValue ofIdentifierName .
- Return a
List containing the StringValue of the secondIdentifierName .
15.2.3.5 Static Semantics: ExportEntries
- Let module be the sole element of ModuleRequests of
FromClause . - Return ExportEntriesForModule of
ExportFromClause with argument module.
- Return ExportEntriesForModule of
NamedExports with argumentnull .
- Let entries be a new empty
List . - Let names be the BoundNames of
VariableStatement . - For each name in names, do
- Append the
ExportEntry Record { [[ModuleRequest]]:null , [[ImportName]]:null , [[LocalName]]: name, [[ExportName]]: name } to entries.
- Append the
- Return entries.
- Let entries be a new empty
List . - Let names be the BoundNames of
Declaration . - For each name in names, do
- Append the
ExportEntry Record { [[ModuleRequest]]:null , [[ImportName]]:null , [[LocalName]]: name, [[ExportName]]: name } to entries.
- Append the
- Return entries.
- Let names be BoundNames of
HoistableDeclaration . - Let localName be the sole element of names.
- Return a new
List containing theExportEntry Record { [[ModuleRequest]]:null , [[ImportName]]:null , [[LocalName]]: localName, [[ExportName]]:"default" }.
- Let names be BoundNames of
ClassDeclaration . - Let localName be the sole element of names.
- Return a new
List containing theExportEntry Record { [[ModuleRequest]]:null , [[ImportName]]:null , [[LocalName]]: localName, [[ExportName]]:"default" }.
- Let entry be the
ExportEntry Record { [[ModuleRequest]]:null , [[ImportName]]:null , [[LocalName]]:"*default*" , [[ExportName]]:"default" }. - Return a new
List containing entry.
15.2.3.6 Static Semantics: ExportEntriesForModule
With parameter module.
- Let entry be the
ExportEntry Record { [[ModuleRequest]]: module, [[ImportName]]:"*" , [[LocalName]]:null , [[ExportName]]:null }. - Return a new
List containing entry.
- Let exportName be the StringValue of
IdentifierName . - Let entry be the
ExportEntry Record { [[ModuleRequest]]: module, [[ImportName]]:"*" , [[LocalName]]:null , [[ExportName]]: exportName }. - Return a new
List containing entry.
- Return a new empty
List .
- Let specs be the ExportEntriesForModule of
ExportsList with argument module. - Append to specs the elements of the ExportEntriesForModule of
ExportSpecifier with argument module. - Return specs.
- Let sourceName be the StringValue of
IdentifierName . - If module is
null , then- Let localName be sourceName.
- Let importName be
null .
- Else,
- Let localName be
null . - Let importName be sourceName.
- Let localName be
- Return a new
List containing theExportEntry Record { [[ModuleRequest]]: module, [[ImportName]]: importName, [[LocalName]]: localName, [[ExportName]]: sourceName }.
- Let sourceName be the StringValue of the first
IdentifierName . - Let exportName be the StringValue of the second
IdentifierName . - If module is
null , then- Let localName be sourceName.
- Let importName be
null .
- Else,
- Let localName be
null . - Let importName be sourceName.
- Let localName be
- Return a new
List containing theExportEntry Record { [[ModuleRequest]]: module, [[ImportName]]: importName, [[LocalName]]: localName, [[ExportName]]: exportName }.
15.2.3.7 Static Semantics: IsConstantDeclaration
- Return
false .
It is not necessary to treat export default
15.2.3.8 Static Semantics: LexicallyScopedDeclarations
- Return a new empty
List .
- Return a new
List containing DeclarationPart ofDeclaration .
- Return a new
List containing DeclarationPart ofHoistableDeclaration .
- Return a new
List containingClassDeclaration .
- Return a new
List containing thisExportDeclaration .
15.2.3.9 Static Semantics: ModuleRequests
- Return the ModuleRequests of
FromClause .
- Return a new empty
List .
15.2.3.10 Static Semantics: ReferencedBindings
- Return a new empty
List .
- Let names be the ReferencedBindings of
ExportsList . - Append to names the elements of the ReferencedBindings of
ExportSpecifier . - Return names.
- Return a
List containing theIdentifierName .
- Return a
List containing the firstIdentifierName .
15.2.3.11 Runtime Semantics: Evaluation
- Return
NormalCompletion (empty ).
- Return the result of evaluating
VariableStatement .
- Return the result of evaluating
Declaration .
- Return the result of evaluating
HoistableDeclaration .
- Let value be ? BindingClassDeclarationEvaluation of
ClassDeclaration . - Let className be the sole element of BoundNames of
ClassDeclaration . - If className is
"*default*" , then- Let env be the
running execution context 's LexicalEnvironment. - Perform ?
InitializeBoundName ("*default*" , value, env).
- Let env be the
- Return
NormalCompletion (empty ).
- If
IsAnonymousFunctionDefinition (AssignmentExpression ) istrue , then- Let value be NamedEvaluation of
AssignmentExpression with argument"default" .
- Let value be NamedEvaluation of
- Else,
- Let rhs be the result of evaluating
AssignmentExpression . - Let value be ?
GetValue (rhs).
- Let rhs be the result of evaluating
- Let env be the
running execution context 's LexicalEnvironment. - Perform ?
InitializeBoundName ("*default*" , value, env). - Return
NormalCompletion (empty ).