From 8cb11390743d236bfd3b71b5b41b9eeb28d77cc5 Mon Sep 17 00:00:00 2001 From: rbuckton Date: Thu, 28 Mar 2024 21:41:10 +0000 Subject: [PATCH] =?UTF-8?q?Deploying=20to=20gh-pages=20from=20@=20tc39/pro?= =?UTF-8?q?posal-discard-binding@f4960d452c7a0ee9d681b6e932a4be9ad42425b7?= =?UTF-8?q?=20=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pr/3/index.html | 4627 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 4627 insertions(+) create mode 100644 pr/3/index.html diff --git a/pr/3/index.html b/pr/3/index.html new file mode 100644 index 0000000..75233b9 --- /dev/null +++ b/pr/3/index.html @@ -0,0 +1,4627 @@ + + + +Discard Bindings
+

Stage 1 Draft / March 28, 2024

Discard Bindings

+ + + + +

Introduction

+

See the proposal repository for background material and discussion.

+
+ + +

8 Syntax-Directed Operations

+ + +

8.2 Scope Analysis

+ + +

8.2.1 Static Semantics: BoundNames

+

The syntax-directed operation BoundNames takes no arguments and returns a List of Strings.

+ Note
+

"*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 ResolveExport ( exportName [ , resolveSet ] ) 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. This "*default*" string is never accessible to ECMAScript code or to the module linking algorithm.

+
+

It is defined piecewise over the following productions:

+ + BindingIdentifier : Identifier + + +
  1. Return a List whose sole element is the StringValue of Identifier.
+ + BindingIdentifier : yield + + +
  1. Return « "yield" ».
+ + BindingIdentifier : await + + +
  1. Return « "await" ».
+ + LexicalDeclaration : + LetOrConst + BindingList + ; + + + +
  1. Return the BoundNames of BindingList.
+ + UsingDeclaration : + using + BindingList + ; + + + + AwaitUsingDeclaration : + CoverAwaitExpressionAndAwaitUsingDeclarationHead + BindingList + ; + + + +
  1. Return the BoundNames of BindingList.
+ + BindingList : + BindingList + , + LexicalBinding + + + +
  1. Let names1 be the BoundNames of BindingList.
  2. Let names2 be the BoundNames of LexicalBinding.
  3. Return the list-concatenation of names1 and names2.
+ + LexicalBinding : + BindingIdentifier + Initializeropt + + + +
  1. Return the BoundNames of BindingIdentifier.
+ + LexicalBinding : + BindingPattern + Initializer + + + +
  1. Return the BoundNames of BindingPattern.
+ + + LexicalBinding : + void + Initializer + + + +
  1. Return a new empty List.
+
+ + VariableDeclarationList : + VariableDeclarationList + , + VariableDeclaration + + + +
  1. Let names1 be BoundNames of VariableDeclarationList.
  2. Let names2 be BoundNames of VariableDeclaration.
  3. Return the list-concatenation of names1 and names2.
+ + VariableDeclaration : + BindingIdentifier + Initializeropt + + + +
  1. Return the BoundNames of BindingIdentifier.
+ + VariableDeclaration : + BindingPattern + Initializer + + + +
  1. Return the BoundNames of BindingPattern.
+ + + BindingPattern : void + + +
  1. Return a new empty List.
+
+ + ObjectBindingPattern : + { + } + + + +
  1. Return a new empty List.
+ + ObjectBindingPattern : + { + BindingPropertyList + , + BindingRestProperty + } + + + +
  1. Let names1 be BoundNames of BindingPropertyList.
  2. Let names2 be BoundNames of BindingRestProperty.
  3. Return the list-concatenation of names1 and names2.
+ + ArrayBindingPattern : + [ + Elisionopt + ] + + + +
  1. Return a new empty List.
+ + ArrayBindingPattern : + [ + Elisionopt + BindingRestElement + ] + + + +
  1. Return the BoundNames of BindingRestElement.
+ + ArrayBindingPattern : + [ + BindingElementList + , + Elisionopt + ] + + + +
  1. Return the BoundNames of BindingElementList.
+ + ArrayBindingPattern : + [ + BindingElementList + , + Elisionopt + BindingRestElement + ] + + + +
  1. Let names1 be BoundNames of BindingElementList.
  2. Let names2 be BoundNames of BindingRestElement.
  3. Return the list-concatenation of names1 and names2.
+ + BindingPropertyList : + BindingPropertyList + , + BindingProperty + + + +
  1. Let names1 be BoundNames of BindingPropertyList.
  2. Let names2 be BoundNames of BindingProperty.
  3. Return the list-concatenation of names1 and names2.
+ + BindingElementList : + BindingElementList + , + BindingElisionElement + + + +
  1. Let names1 be BoundNames of BindingElementList.
  2. Let names2 be BoundNames of BindingElisionElement.
  3. Return the list-concatenation of names1 and names2.
+ + BindingElisionElement : + Elisionopt + BindingElement + + + +
  1. Return BoundNames of BindingElement.
+ + BindingProperty : + PropertyName + : + BindingElement + + + +
  1. Return the BoundNames of BindingElement.
+ + SingleNameBinding : + BindingIdentifier + Initializeropt + + + +
  1. Return the BoundNames of BindingIdentifier.
+ + BindingElement : + BindingPattern + Initializeropt + + + +
  1. Return the BoundNames of BindingPattern.
+ + ForDeclaration : + LetOrConst + ForBinding + + + +
  1. Return the BoundNames of ForBinding.
+ + FunctionDeclaration : + function + BindingIdentifier + ( + FormalParameters + ) + { + FunctionBody + } + + + +
  1. Return the BoundNames of BindingIdentifier.
+ + FunctionDeclaration : + function + ( + FormalParameters + ) + { + FunctionBody + } + + + +
  1. Return « "*default*" ».
+ + FormalParameters : [empty] + + +
  1. Return a new empty List.
+ + FormalParameters : + FormalParameterList + , + FunctionRestParameter + + + +
  1. Let names1 be BoundNames of FormalParameterList.
  2. Let names2 be BoundNames of FunctionRestParameter.
  3. Return the list-concatenation of names1 and names2.
+ + FormalParameterList : + FormalParameterList + , + FormalParameter + + + +
  1. Let names1 be BoundNames of FormalParameterList.
  2. Let names2 be BoundNames of FormalParameter.
  3. Return the list-concatenation of names1 and names2.
+ + ArrowParameters : CoverParenthesizedExpressionAndArrowParameterList + + +
  1. Let formals be the ArrowFormalParameters that is covered by CoverParenthesizedExpressionAndArrowParameterList.
  2. Return the BoundNames of formals.
+ + GeneratorDeclaration : + function + * + BindingIdentifier + ( + FormalParameters + ) + { + GeneratorBody + } + + + +
  1. Return the BoundNames of BindingIdentifier.
+ + GeneratorDeclaration : + function + * + ( + FormalParameters + ) + { + GeneratorBody + } + + + +
  1. Return « "*default*" ».
+ + AsyncGeneratorDeclaration : + async + function + * + BindingIdentifier + ( + FormalParameters + ) + { + AsyncGeneratorBody + } + + + +
  1. Return the BoundNames of BindingIdentifier.
+ + AsyncGeneratorDeclaration : + async + function + * + ( + FormalParameters + ) + { + AsyncGeneratorBody + } + + + +
  1. Return « "*default*" ».
+ + ClassDeclaration : + class + BindingIdentifier + ClassTail + + + +
  1. Return the BoundNames of BindingIdentifier.
+ + ClassDeclaration : + class + ClassTail + + + +
  1. Return « "*default*" ».
+ + AsyncFunctionDeclaration : + async + function + BindingIdentifier + ( + FormalParameters + ) + { + AsyncFunctionBody + } + + + +
  1. Return the BoundNames of BindingIdentifier.
+ + AsyncFunctionDeclaration : + async + function + ( + FormalParameters + ) + { + AsyncFunctionBody + } + + + +
  1. Return « "*default*" ».
+ + CoverCallExpressionAndAsyncArrowHead : + MemberExpression + Arguments + + + +
  1. Let head be the AsyncArrowHead that is covered by CoverCallExpressionAndAsyncArrowHead.
  2. Return the BoundNames of head.
+ + ImportDeclaration : + import + ImportClause + FromClause + ; + + + +
  1. Return the BoundNames of ImportClause.
+ + ImportDeclaration : + import + ModuleSpecifier + ; + + + +
  1. Return a new empty List.
+ + ImportClause : + ImportedDefaultBinding + , + NameSpaceImport + + + +
  1. Let names1 be the BoundNames of ImportedDefaultBinding.
  2. Let names2 be the BoundNames of NameSpaceImport.
  3. Return the list-concatenation of names1 and names2.
+ + ImportClause : + ImportedDefaultBinding + , + NamedImports + + + +
  1. Let names1 be the BoundNames of ImportedDefaultBinding.
  2. Let names2 be the BoundNames of NamedImports.
  3. Return the list-concatenation of names1 and names2.
+ + NamedImports : + { + } + + + +
  1. Return a new empty List.
+ + ImportsList : + ImportsList + , + ImportSpecifier + + + +
  1. Let names1 be the BoundNames of ImportsList.
  2. Let names2 be the BoundNames of ImportSpecifier.
  3. Return the list-concatenation of names1 and names2.
+ + ImportSpecifier : + ModuleExportName + as + ImportedBinding + + + +
  1. Return the BoundNames of ImportedBinding.
+ + ExportDeclaration : + export + ExportFromClause + FromClause + ; + + + export + NamedExports + ; + + + +
  1. Return a new empty List.
+ + ExportDeclaration : + export + VariableStatement + + + +
  1. Return the BoundNames of VariableStatement.
+ + ExportDeclaration : + export + Declaration + + + +
  1. Return the BoundNames of Declaration.
+ + ExportDeclaration : + export + default + HoistableDeclaration + + + +
  1. Let declarationNames be the BoundNames of HoistableDeclaration.
  2. If declarationNames does not include the element "*default*", append "*default*" to declarationNames.
  3. Return declarationNames.
+ + ExportDeclaration : + export + default + ClassDeclaration + + + +
  1. Let declarationNames be the BoundNames of ClassDeclaration.
  2. If declarationNames does not include the element "*default*", append "*default*" to declarationNames.
  3. Return declarationNames.
+ + ExportDeclaration : + export + default + AssignmentExpression + ; + + + +
  1. Return « "*default*" ».
+
+
+ + +

8.4 Function Name Inference

+ + +

8.4.4 Static Semantics: IsIdentifierRef

+

The syntax-directed operation IsIdentifierRef takes no arguments and returns a Boolean. It is defined piecewise over the following productions:

+ + PrimaryExpression : IdentifierReference + + +
  1. Return true.
+ + PrimaryExpression : + this + + + Literal + + + ArrayLiteral + + + ObjectLiteral + + + FunctionExpression + + + ClassExpression + + + GeneratorExpression + + + AsyncFunctionExpression + + + AsyncGeneratorExpression + + + RegularExpressionLiteral + + + TemplateLiteral + + + CoverParenthesizedExpressionAndArrowParameterList + + + + MemberExpression : + MemberExpression + [ + Expression + ] + + + MemberExpression + . + IdentifierName + + + MemberExpression + TemplateLiteral + + + SuperProperty + + + MetaProperty + + + new + MemberExpression + Arguments + + + MemberExpression + . + PrivateIdentifier + + + + NewExpression : + new + NewExpression + + + + LeftHandSideExpression : + CallExpression + + + OptionalExpression + + + + DestructuringAssignmentTarget : + void + + + +
  1. Return false.
+
+
+ + +

8.6 Miscellaneous

+ +

8.6.1 Runtime Semantics: BindingInitialization

+

The syntax-directed operation BindingInitialization takes arguments value (an ECMAScript language value) and environment (an Environment Record or undefined) and returns either a normal completion containing unused or an abrupt completion.

+ Note
+

undefined is passed for environment to indicate that a PutValue operation should be used to assign the initialization value. This is the case for var statements and formal parameter lists of some non-strict functions (See 10.2.11). In those cases a lexical binding is hoisted and preinitialized prior to evaluation of its initializer.

+
+

It is defined piecewise over the following productions:

+ + BindingIdentifier : Identifier + + +
  1. Let name be StringValue of Identifier.
  2. Return ? InitializeBoundName(name, value, environment).
+ + BindingIdentifier : yield + + +
  1. Return ? InitializeBoundName("yield", value, environment).
+ + BindingIdentifier : await + + +
  1. Return ? InitializeBoundName("await", value, environment).
+ + BindingPattern : ObjectBindingPattern + + +
  1. Perform ? RequireObjectCoercible(value).
  2. Return ? BindingInitialization of ObjectBindingPattern with arguments value and environment.
+ + BindingPattern : ArrayBindingPattern + + +
  1. Let iteratorRecord be ? GetIterator(value, sync).
  2. Let result be Completion(IteratorBindingInitialization of ArrayBindingPattern with arguments iteratorRecord and environment).
  3. If iteratorRecord.[[Done]] is false, return ? IteratorClose(iteratorRecord, result).
  4. Return ? result.
+ + + BindingPattern : void + + +
  1. Return unused.
+
+ + ObjectBindingPattern : + { + } + + + +
  1. Return unused.
+ + ObjectBindingPattern : + { + BindingPropertyList + } + + + { + BindingPropertyList + , + } + + + +
  1. Perform ? PropertyBindingInitialization of BindingPropertyList with arguments value and environment.
  2. Return unused.
+ + ObjectBindingPattern : + { + BindingRestProperty + } + + + +
  1. Let excludedNames be a new empty List.
  2. Return ? RestBindingInitialization of BindingRestProperty with arguments value, environment, and excludedNames.
+ + ObjectBindingPattern : + { + BindingPropertyList + , + BindingRestProperty + } + + + +
  1. Let excludedNames be ? PropertyBindingInitialization of BindingPropertyList with arguments value and environment.
  2. Return ? RestBindingInitialization of BindingRestProperty with arguments value, environment, and excludedNames.
+
+
+
+ + +

13 ECMAScript Language: Expressions

+ + +

13.5 Unary Operators

+

Syntax

+ + UnaryExpression[Yield, Await] : + UpdateExpression[?Yield, ?Await] + + + delete + UnaryExpression[?Yield, ?Await] + + + void + UnaryExpression[?Yield, ?Await] + + + CoverVoidExpressionAndVoidDiscard[?Yield, ?Await] + + + typeof + UnaryExpression[?Yield, ?Await] + + + + + UnaryExpression[?Yield, ?Await] + + + - + UnaryExpression[?Yield, ?Await] + + + ~ + UnaryExpression[?Yield, ?Await] + + + ! + UnaryExpression[?Yield, ?Await] + + [+Await] + CoverAwaitExpressionAndAwaitUsingDeclarationHead[?Yield] + + + + CoverAwaitExpressionAndAwaitUsingDeclarationHead[Yield] : + await + UnaryExpression[?Yield, +Await] + + + + CoverVoidExpressionAndVoidDiscard[Yield, Await] : + void + UnaryExpression[?Yield, ?Await]opt + + + + + +

13.5.2 The void Operator

+ + +

Supplemental Syntax

+

+ In certain circumstances when processing an instance of the production
+ + UnaryExpression : CoverVoidExpressionAndVoidDiscard + +
+ the interpretation of CoverVoidExpressionAndVoidDiscard is refined using the following grammar: +

+ + VoidExpression[Yield, Await] : + void + UnaryExpression[?Yield, ?Await] + + + +
+ + +

13.5.2.1 Runtime Semantics: Evaluation

+ + + UnaryExpression : CoverVoidExpressionAndVoidDiscard + + +
  1. Let voidExpr be the VoidExpression that is covered by CoverVoidExpressionAndVoidDiscard.
  2. Let expr be ? Evaluation of voidExpr.
  3. Perform ? GetValue(expr).
  4. Return undefined.
+
+ + UnaryExpression : + void + UnaryExpression + + + + VoidExpression : + void + UnaryExpression + + + +
  1. Let expr be ? Evaluation of UnaryExpression.
  2. Perform ? GetValue(expr).
  3. Return undefined.
+ Note
+

GetValue must be called even though its value is not used because it may have observable side-effects.

+
+
+
+
+ + +

13.15 Assignment Operators

+ + + +

13.15.5 Destructuring Assignment

+

Supplemental Syntax

+

+ In certain circumstances when processing an instance of the production
+ + AssignmentExpression : + LeftHandSideExpression + = + AssignmentExpression + + +
+ the interpretation of LeftHandSideExpression is refined using the following grammar: +

+ + AssignmentPattern[Yield, Await] : + ObjectAssignmentPattern[?Yield, ?Await] + + + ArrayAssignmentPattern[?Yield, ?Await] + + + + ObjectAssignmentPattern[Yield, Await] : + { + } + + + { + AssignmentRestProperty[?Yield, ?Await] + } + + + { + AssignmentPropertyList[?Yield, ?Await] + } + + + { + AssignmentPropertyList[?Yield, ?Await] + , + AssignmentRestProperty[?Yield, ?Await]opt + } + + + + ArrayAssignmentPattern[Yield, Await] : + [ + Elisionopt + AssignmentRestElement[?Yield, ?Await]opt + ] + + + [ + AssignmentElementList[?Yield, ?Await] + ] + + + [ + AssignmentElementList[?Yield, ?Await] + , + Elisionopt + AssignmentRestElement[?Yield, ?Await]opt + ] + + + + AssignmentRestProperty[Yield, Await] : + ... + DestructuringAssignmentTarget[?Yield, ?Await] + + + + AssignmentPropertyList[Yield, Await] : + AssignmentProperty[?Yield, ?Await] + + + AssignmentPropertyList[?Yield, ?Await] + , + AssignmentProperty[?Yield, ?Await] + + + + AssignmentElementList[Yield, Await] : + AssignmentElisionElement[?Yield, ?Await] + + + AssignmentElementList[?Yield, ?Await] + , + AssignmentElisionElement[?Yield, ?Await] + + + + AssignmentElisionElement[Yield, Await] : + Elisionopt + AssignmentElement[?Yield, ?Await] + + + + AssignmentProperty[Yield, Await] : + IdentifierReference[?Yield, ?Await] + Initializer[+In, ?Yield, ?Await]opt + + + PropertyName[?Yield, ?Await] + : + AssignmentElement[?Yield, ?Await] + + + + AssignmentElement[Yield, Await] : + DestructuringAssignmentTarget[?Yield, ?Await] + Initializer[+In, ?Yield, ?Await]opt + + + + AssignmentRestElement[Yield, Await] : + ... + DestructuringAssignmentTarget[?Yield, ?Await] + + + + DestructuringAssignmentTarget[Yield, Await] : + LeftHandSideExpression[?Yield, ?Await] + + + void + + + + + +

13.15.5.1 Static Semantics: Early Errors

+ + AssignmentProperty : + IdentifierReference + Initializeropt + + + + + + AssignmentRestProperty : + ... + DestructuringAssignmentTarget + + + + + + DestructuringAssignmentTarget : LeftHandSideExpression + + + +
+ + +

13.15.5.5 Runtime Semantics: IteratorDestructuringAssignmentEvaluation

+

The syntax-directed operation IteratorDestructuringAssignmentEvaluation takes argument iteratorRecord (an Iterator Record) and returns either a normal completion containing unused or an abrupt completion. It is defined piecewise over the following productions:

+ + AssignmentElementList : AssignmentElisionElement + + +
  1. Return ? IteratorDestructuringAssignmentEvaluation of AssignmentElisionElement with argument iteratorRecord.
+ + AssignmentElementList : + AssignmentElementList + , + AssignmentElisionElement + + + +
  1. Perform ? IteratorDestructuringAssignmentEvaluation of AssignmentElementList with argument iteratorRecord.
  2. Return ? IteratorDestructuringAssignmentEvaluation of AssignmentElisionElement with argument iteratorRecord.
+ + AssignmentElisionElement : AssignmentElement + + +
  1. Return ? IteratorDestructuringAssignmentEvaluation of AssignmentElement with argument iteratorRecord.
+ + AssignmentElisionElement : + Elision + AssignmentElement + + + +
  1. Perform ? IteratorDestructuringAssignmentEvaluation of Elision with argument iteratorRecord.
  2. Return ? IteratorDestructuringAssignmentEvaluation of AssignmentElement with argument iteratorRecord.
+ + Elision : , + + +
  1. If iteratorRecord.[[Done]] is false, then
    1. Let next be Completion(IteratorStep(iteratorRecord)).
    2. If next is an abrupt completion, set iteratorRecord.[[Done]] to true.
    3. ReturnIfAbrupt(next).
    4. If next is false, set iteratorRecord.[[Done]] to true.
  2. Return unused.
+ + Elision : + Elision + , + + + +
  1. Perform ? IteratorDestructuringAssignmentEvaluation of Elision with argument iteratorRecord.
  2. If iteratorRecord.[[Done]] is false, then
    1. Let next be Completion(IteratorStep(iteratorRecord)).
    2. If next is an abrupt completion, set iteratorRecord.[[Done]] to true.
    3. ReturnIfAbrupt(next).
    4. If next is false, set iteratorRecord.[[Done]] to true.
  3. Return unused.
+ + AssignmentElement : + DestructuringAssignmentTarget + Initializeropt + + + +
  1. If DestructuringAssignmentTarget is neither an ObjectLiteral nor, an ArrayLiteral, nor void, then
    1. Let lref be ? Evaluation of DestructuringAssignmentTarget.
  2. Let value be undefined.
  3. If iteratorRecord.[[Done]] is false, then
    1. Let next be ? IteratorStepValue(iteratorRecord).
    2. If next is not done, then
      1. Set value to next.
  4. If Initializer is present and value is undefined, then
    1. If IsAnonymousFunctionDefinition(Initializer) is true and IsIdentifierRef of DestructuringAssignmentTarget is true, then
      1. Let v be ? NamedEvaluation of Initializer with argument lref.[[ReferencedName]].
    2. Else,
      1. Let defaultValue be ? Evaluation of Initializer.
      2. Let v be ? GetValue(defaultValue).
  5. Else,
    1. Let v be value.
  6. If DestructuringAssignmentTarget is either an ObjectLiteral or an ArrayLiteral, then
    1. Let nestedAssignmentPattern be the AssignmentPattern that is covered by DestructuringAssignmentTarget.
    2. Return ? DestructuringAssignmentEvaluation of nestedAssignmentPattern with argument v.
  7. If DestructuringAssignmentTarget is void, then
    1. Return unused.
  8. Return ? PutValue(lref, v).
+ Note
+

Left to right evaluation order is maintained by evaluating a DestructuringAssignmentTarget that is not a destructuring pattern prior to accessing the iterator or evaluating the Initializer.

+
+ + AssignmentRestElement : + ... + DestructuringAssignmentTarget + + + +
  1. If DestructuringAssignmentTarget is neither an ObjectLiteral nor, an ArrayLiteral, nor void, then
    1. Let lref be ? Evaluation of DestructuringAssignmentTarget.
  2. Let A be ! ArrayCreate(0).
  3. Let n be 0.
  4. Repeat, while iteratorRecord.[[Done]] is false,
    1. Let next be ? IteratorStepValue(iteratorRecord).
    2. If next is not done, then
      1. Perform ! CreateDataPropertyOrThrow(A, ! ToString(𝔽(n)), next).
      2. Set n to n + 1.
  5. If DestructuringAssignmentTarget is neither an ObjectLiteral nor an ArrayLiteral, then
    1. Return ? PutValue(lref, A).
  6. Let nestedAssignmentPattern be the AssignmentPattern that is covered by DestructuringAssignmentTarget.
  7. Return ? DestructuringAssignmentEvaluation of nestedAssignmentPattern with argument A.
  8. If DestructuringAssignmentTarget is either an ObjectLiteral or an ArrayLiteral, then
    1. Let nestedAssignmentPattern be the AssignmentPattern that is covered by DestructuringAssignmentTarget.
    2. Return ? DestructuringAssignmentEvaluation of nestedAssignmentPattern with argument A.
  9. If DestructuringAssignmentTarget is void, then
    1. Return unused.
  10. Return ? PutValue(lref, A).
+
+ + +

13.15.5.6 Runtime Semantics: KeyedDestructuringAssignmentEvaluation

+

The syntax-directed operation KeyedDestructuringAssignmentEvaluation takes arguments value (an ECMAScript language value) and propertyName (a property key) and returns either a normal completion containing unused or an abrupt completion. It is defined piecewise over the following productions:

+ + AssignmentElement : + DestructuringAssignmentTarget + Initializeropt + + + +
  1. If DestructuringAssignmentTarget is neither an ObjectLiteral nor an ArrayLiteral nor void, then
    1. Let lref be ? Evaluation of DestructuringAssignmentTarget.
  2. Let v be ? GetV(value, propertyName).
  3. If Initializer is present and v is undefined, then
    1. If IsAnonymousFunctionDefinition(Initializer) and IsIdentifierRef of DestructuringAssignmentTarget are both true, then
      1. Let rhsValue be ? NamedEvaluation of Initializer with argument lref.[[ReferencedName]].
    2. Else,
      1. Let defaultValue be ? Evaluation of Initializer.
      2. Let rhsValue be ? GetValue(defaultValue).
  4. Else,
    1. Let rhsValue be v.
  5. If DestructuringAssignmentTarget is either an ObjectLiteral or an ArrayLiteral, then
    1. Let assignmentPattern be the AssignmentPattern that is covered by DestructuringAssignmentTarget.
    2. Return ? DestructuringAssignmentEvaluation of assignmentPattern with argument rhsValue.
  6. If DestructuringAssignmentTarget is void, then
    1. Return unused.
  7. Return ? PutValue(lref, rhsValue).
+
+
+
+
+ + +

14 ECMAScript Language: Statements and Declarations

+ +

14.3 Declarations and the Variable Statement

+ +

14.3.1 Let, Const, Using, and Await Using Declarations

+ +

Syntax

+ + LexicalDeclaration[In, Yield, Await] : + LetOrConst + BindingList[?In, ?Yield, ?Await, +Pattern] + ; + + + UsingDeclaration[?In, ?Yield, ?Await] + + [+Await] + AwaitUsingDeclaration[?In, ?Yield] + + + + LetOrConst : + let + + + const + + + + UsingDeclaration[In, Yield, Await] : + using + [no LineTerminator here] + BindingList[?In, ?Yield, ?Await, ~Pattern] + ; + + + + AwaitUsingDeclaration[In, Yield] : + CoverAwaitExpressionAndAwaitUsingDeclarationHead[?Yield] + [no LineTerminator here] + BindingList[?In, ?Yield, +Await, ~Pattern] + ; + + + + BindingList[In, Yield, Await, Pattern] : + LexicalBinding[?In, ?Yield, ?Await, ?Pattern] + + + BindingList[?In, ?Yield, ?Await, ?Pattern] + , + LexicalBinding[?In, ?Yield, ?Await, ?Pattern] + + + + LexicalBinding[In, Yield, Await, Pattern] : + BindingIdentifier[?Yield, ?Await] + Initializer[?In, ?Yield, ?Await]opt + + [+Pattern] + BindingPattern[?Yield, ?Await, ~Void] + Initializer[?In, ?Yield, ?Await] + + [~Pattern] + void + Initializer[?In, ?Yield, ?Await] + + + + + +

14.3.1.2 Runtime Semantics: BindingEvaluation

+

The syntax-directed operation BindingEvaluation takes argument hint (one of normal, sync-dispose, or async-dispose) and returns either a normal completion containing unused or an abrupt completion. It is defined piecewise over the following productions:

+ + BindingList : + BindingList + , + LexicalBinding + + + +
  1. Perform ? BindingEvaluation of BindingList with argument hint.
  2. Return ? BindingEvaluation of LexicalBinding with argument hint.
+ + LexicalBinding : BindingIdentifier + + +
  1. Assert: hint is normal.
  2. Let lhs be ! ResolveBinding(StringValue of BindingIdentifier).
  3. Perform ! InitializeReferencedBinding(lhs, undefined, normal).
  4. Return unused.
+ Note
+

A static semantics rule ensures that this form of LexicalBinding never occurs in a const, using, or await using declaration.

+
+ + LexicalBinding : + BindingIdentifier + Initializer + + + +
  1. Let bindingId be StringValue of BindingIdentifier.
  2. Let lhs be ! ResolveBinding(bindingId).
  3. If IsAnonymousFunctionDefinition(Initializer) is true, then
    1. Let value be ? NamedEvaluation of Initializer with argument bindingId.
  4. Else,
    1. Let rhs be ? Evaluation of Initializer.
    2. Let value be ? GetValue(rhs).
  5. Perform ? InitializeReferencedBinding(lhs, value, hint).
  6. Return unused.
+ + + LexicalBinding : + void + Initializer + + + +
  1. Assert: hint is not normal.
  2. Let env be the running execution context's LexicalEnvironment.
  3. Assert: env is an Environment Record.
  4. Let rhs be ? Evaluation of Initializer.
  5. Let value be ? GetValue(rhs).
  6. Perform ? AddDisposableResource(env.[[DisposeCapability]], value, hint).
  7. Return unused.
+
+ + LexicalBinding : + BindingPattern + Initializer + + + +
  1. Assert: hint is normal.
  2. Let rhs be ? Evaluation of Initializer.
  3. Let value be ? GetValue(rhs).
  4. Let env be the running execution context's LexicalEnvironment.
  5. Return ? BindingInitialization of BindingPattern with arguments value and env.
+
+
+ + +

14.3.2 Variable Statement

+

Syntax

+ + VariableStatement[Yield, Await] : + var + VariableDeclarationList[+In, ?Yield, ?Await] + ; + + + + VariableDeclarationList[In, Yield, Await] : + VariableDeclaration[?In, ?Yield, ?Await] + + + VariableDeclarationList[?In, ?Yield, ?Await] + , + VariableDeclaration[?In, ?Yield, ?Await] + + + + VariableDeclaration[In, Yield, Await] : + BindingIdentifier[?Yield, ?Await] + Initializer[?In, ?Yield, ?Await]opt + + + BindingPattern[?Yield, ?Await, ~Void] + Initializer[?In, ?Yield, ?Await] + + + +
+ + +

14.3.3 Destructuring Binding Patterns

+

Syntax

+ + BindingPattern[Yield, Await, Void] : + ObjectBindingPattern[?Yield, ?Await] + + + ArrayBindingPattern[?Yield, ?Await] + + [+Void] + void + + + + ObjectBindingPattern[Yield, Await] : + { + } + + + { + BindingRestProperty[?Yield, ?Await] + } + + + { + BindingPropertyList[?Yield, ?Await] + } + + + { + BindingPropertyList[?Yield, ?Await] + , + BindingRestProperty[?Yield, ?Await]opt + } + + + + ArrayBindingPattern[Yield, Await] : + [ + Elisionopt + BindingRestElement[?Yield, ?Await]opt + ] + + + [ + BindingElementList[?Yield, ?Await] + ] + + + [ + BindingElementList[?Yield, ?Await] + , + Elisionopt + BindingRestElement[?Yield, ?Await]opt + ] + + + + BindingRestProperty[Yield, Await] : + ... + BindingIdentifier[?Yield, ?Await] + + + + BindingPropertyList[Yield, Await] : + BindingProperty[?Yield, ?Await] + + + BindingPropertyList[?Yield, ?Await] + , + BindingProperty[?Yield, ?Await] + + + + BindingElementList[Yield, Await] : + BindingElisionElement[?Yield, ?Await] + + + BindingElementList[?Yield, ?Await] + , + BindingElisionElement[?Yield, ?Await] + + + + BindingElisionElement[Yield, Await] : + Elisionopt + BindingElement[?Yield, ?Await] + + + + BindingProperty[Yield, Await] : + SingleNameBinding[?Yield, ?Await] + + + PropertyName[?Yield, ?Await] + : + BindingElement[?Yield, ?Await] + + + + BindingElement[Yield, Await] : + SingleNameBinding[?Yield, ?Await] + + + BindingPattern[?Yield, ?Await, +Void] + Initializer[+In, ?Yield, ?Await]opt + + + + SingleNameBinding[Yield, Await] : + BindingIdentifier[?Yield, ?Await] + Initializer[+In, ?Yield, ?Await]opt + + + + BindingRestElement[Yield, Await] : + ... + BindingIdentifier[?Yield, ?Await] + + + ... + BindingPattern[?Yield, ?Await, +Void] + + + +
+
+
+

A Copyright & Software License

+ +

Copyright Notice

+

© 2024 Ron Buckton, Ecma International

+ +

Software License

+

All Software contained in this document ("Software") is protected by copyright and is being made available under the "BSD License", included below. This Software may be subject to third party rights (rights from parties other than Ecma International), including patent rights, and no licenses under such third party rights are granted under this license even if the third party concerned is a member of Ecma International. SEE THE ECMA CODE OF CONDUCT IN PATENT MATTERS AVAILABLE AT https://ecma-international.org/memento/codeofconduct.htm FOR INFORMATION REGARDING THE LICENSING OF PATENT CLAIMS THAT ARE REQUIRED TO IMPLEMENT ECMA INTERNATIONAL STANDARDS.

+ +

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

+ +
    +
  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. +
  3. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  4. +
  5. Neither the name of the authors nor Ecma International may be used to endorse or promote products derived from this software without specific prior written permission.
  6. +
+ +

THIS SOFTWARE IS PROVIDED BY THE ECMA INTERNATIONAL "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ECMA INTERNATIONAL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

+ +
+
\ No newline at end of file