diff --git a/spec.html b/spec.html
index acdd9d74e0..7a74c36c09 100644
--- a/spec.html
+++ b/spec.html
@@ -1370,6 +1370,17 @@
%Symbol%
@@ -7361,6 +7416,246 @@
+
+
+ Operations on Disposable Objects
+ See Common Resource Management Interfaces ().
+
+
+ DisposeCapability Records
+ A DisposeCapability Record is a Record value used to contain a List of DisposableResource Records that are disposed together. DisposeCapability Records are produced by the NewDisposeCapability abstract operation.
+ DisposeCapability Records have the fields listed in :
+
+
+
+ |
+ Field Name
+ |
+
+ Value
+ |
+
+ Meaning
+ |
+
+
+ |
+ [[DisposableResourceStack]]
+ |
+
+ a List of DisposableResource Records
+ |
+
+ The resources to be disposed. Resources are added in the order they are initialized, and are disposed in reverse order.
+ |
+
+
+
+
+
+
+ DisposableResource Records
+ A DisposableResource Record is a Record value used to encapsulate a disposable object along with the method used to dispose the object. DisposableResource Records are produced by the CreateDisposableResource abstract operation.
+ DisposableResource Records have the fields listed in :
+
+
+
+ |
+ Field Name
+ |
+
+ Value
+ |
+
+ Meaning
+ |
+
+
+ |
+ [[ResourceValue]]
+ |
+
+ an Object or *undefined*
+ |
+
+ The value to be disposed.
+ |
+
+
+ |
+ [[Kind]]
+ |
+
+ ~sync-dispose~ or ~async-dispose~
+ |
+
+ Indicates whether the resource was added by a `using` declaration or DisposableStack object (~sync-dispose~) or by an `await using` declaration or AsyncDisposableStack object (~async-dispose~).
+ |
+
+
+ |
+ [[DisposeMethod]]
+ |
+
+ a function object or *undefined*
+ |
+
+ A function object that will be called with [[ResourceValue]] as its *this* value when the resource disposed.
+ |
+
+
+
+
+
+
+ NewDisposeCapability ( ): a DisposeCapability Record
+
+
+ 1. Return the DisposeCapability Record { [[DisposableResourceStack]]: « » }.
+
+
+
+
+
+ AddDisposableResource (
+ _disposeCapability_: a DisposeCapability Record,
+ _value_: an ECMAScript language value,
+ _kind_: ~sync-dispose~ or ~async-dispose~,
+ optional _method_: a function object,
+ ): either a normal completion containing ~unused~ or a throw completion
+
+
+
+ 1. If _method_ is not present, then
+ 1. If _value_ is either *null* or *undefined* and _kind_ is ~sync-dispose~, return ~unused~.
+ 1. NOTE: When _value_ is either *null* or *undefined* and _kind_ is ~async-dispose~, we record that the resource was evaluated to ensure we will still perform an Await when resources are later disposed.
+ 1. Let _resource_ be ? CreateDisposableResource(_value_, _kind_).
+ 1. Else,
+ 1. Assert: _value_ is *undefined*.
+ 1. Let _resource_ be ? CreateDisposableResource(*undefined*, _kind_, _method_).
+ 1. Append _resource_ to _disposeCapability_.[[DisposableResourceStack]].
+ 1. Return ~unused~.
+
+
+
+
+
+ CreateDisposableResource (
+ _value_: an ECMAScript language value,
+ _kind_: ~sync-dispose~ or ~async-dispose~,
+ optional _method_: a function object,
+ ): either a normal completion containing a DisposableResource Record or a throw completion
+
+
+
+ 1. If _method_ is not present, then
+ 1. If _value_ is either *null* or *undefined*, then
+ 1. Set _value_ to *undefined*.
+ 1. Set _method_ to *undefined*.
+ 1. Else,
+ 1. Set _method_ to ? GetDisposeMethod(_value_, _kind_).
+ 1. If _method_ is *undefined*, throw a *TypeError* exception.
+ 1. Return the DisposableResource Record { [[ResourceValue]]: _value_, [[Kind]]: _kind_, [[DisposeMethod]]: _method_ }.
+
+
+
+
+
+ GetDisposeMethod (
+ _value_: an ECMAScript language value,
+ _kind_: ~sync-dispose~ or ~async-dispose~,
+ ): either a normal completion containing either a function object or *undefined*, or a throw completion
+
+
+
+ 1. If _value_ is not an Object, throw a *TypeError* exception.
+ 1. If _kind_ is ~sync-dispose~, return ? GetMethod(_value_, %Symbol.dispose%).
+ 1. Assert: _kind_ is ~async-dispose~.
+ 1. Let _asyncMethod_ be ? GetMethod(_value_, %Symbol.asyncDispose%).
+ 1. If _asyncMethod_ is not *undefined*, return _asyncMethod_.
+ 1. Let _syncMethod_ be ? GetMethod(_value_, %Symbol.dispose%).
+ 1. If _syncMethod_ is *undefined*, return *undefined*.
+ 1. Let _closure_ be a new Abstract Closure with no parameters that captures _syncMethod_ and performs the following steps when called:
+ 1. Let _obj_ be the *this* value.
+ 1. Let _promiseCapability_ be ! NewPromiseCapability(%Promise%).
+ 1. Let _result_ be Completion(Call(_syncMethod_, _obj_)).
+ 1. IfAbruptRejectPromise(_result_, _promiseCapability_).
+ 1. Perform ! Call(_promiseCapability_.[[Resolve]], *undefined*, « *undefined* »).
+ 1. Return _promiseCapability_.[[Promise]].
+ 1. NOTE: This function is not observable to user code. It is used to ensure that a Promise returned from a synchronous `%Symbol.dispose%` method will not be awaited and that a synchronous exception will be translated to a rejected Promise.
+ 1. Return CreateBuiltinFunction(_closure_, 0, *""*, « »).
+
+
+
+
+
+ Dispose (
+ _value_: an Object or *undefined*,
+ _kind_: ~sync-dispose~ or ~async-dispose~,
+ _method_: a function object or *undefined*,
+ ): either a normal completion containing *undefined* or a throw completion
+
+
+
+ 1. If _method_ is *undefined*, let _result_ be *undefined*.
+ 1. Else, let _result_ be ? Call(_method_, _value_).
+ 1. If _kind_ is ~async-dispose~, then
+ 1. Perform ? Await(_result_).
+ 1. Return *undefined*.
+
+
+
+
+
+ DisposeResources (
+ _disposeCapability_: a DisposeCapability Record,
+ _completion_: either a normal completion containing either an ECMAScript language value or ~empty~, or an abrupt completion,
+ ): either a normal completion containing either an ECMAScript language value or ~empty~, or an abrupt completion
+
+
+
+ 1. Let _needsAwait_ be *false*.
+ 1. Let _hasAwaited_ be *false*.
+ 1. Let _outputCompletion_ be _completion_.
+ 1. For each element _resource_ of _disposeCapability_.[[DisposableResourceStack]], in reverse List order, do
+ 1. Let _value_ be _resource_.[[ResourceValue]].
+ 1. Let _kind_ be _resource_.[[Kind]].
+ 1. Let _method_ be _resource_.[[DisposeMethod]].
+ 1. If _kind_ is ~sync-dispose~, _needsAwait_ is *true*, and _hasAwaited_ is *false*, then
+ 1. Perform ! Await(*undefined*).
+ 1. Set _needsAwait_ to *false*.
+ 1. If _method_ is not *undefined*, then
+ 1. Let _result_ be Completion(Call(_method_, _value_)).
+ 1. If _result_ is a normal completion and _kind_ is ~async-dispose~, then
+ 1. Set _result_ to Completion(Await(_result_.[[Value]])).
+ 1. Set _hasAwaited_ to *true*.
+ 1. If _result_ is a throw completion, then
+ 1. If _outputCompletion_ is a throw completion, then
+ 1. Set _result_ to _result_.[[Value]].
+ 1. Let _suppressed_ be _outputCompletion_.[[Value]].
+ 1. Let _error_ be a newly created *SuppressedError* object.
+ 1. Perform CreateNonEnumerableDataPropertyOrThrow(_error_, *"error"*, _result_).
+ 1. Perform CreateNonEnumerableDataPropertyOrThrow(_error_, *"suppressed"*, _suppressed_).
+ 1. Set _outputCompletion_ to ThrowCompletion(_error_).
+ 1. Else,
+ 1. Set _outputCompletion_ to _result_.
+ 1. Else,
+ 1. Assert: _kind_ is ~async-dispose~.
+ 1. Set _needsAwait_ to *true*.
+ 1. NOTE: This can only indicate a case where either *null* or *undefined* was the initialized value of an `await using` declaration.
+ 1. If _needsAwait_ is *true* and _hasAwaited_ is *false*, then
+ 1. Perform ! Await(*undefined*).
+ 1. NOTE: After _disposeCapability_ has been disposed, it will never be used again. The contents of _disposeCapability_.[[DisposableResourceStack]] can be discarded in implementations, such as by garbage collection, at this point.
+ 1. Return ? _outputCompletion_.
+
+
+
@@ -7404,6 +7699,16 @@ Static Semantics: BoundNames ( ): a List of Strings
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|.
@@ -7678,6 +7983,16 @@ Static Semantics: IsConstantDeclaration ( ): a Boolean
1. Return *true*.
+
+ UsingDeclaration :
+ `using` BindingList `;`
+
+ AwaitUsingDeclaration :
+ CoverAwaitExpressionAndAwaitUsingDeclarationHead BindingList `;`
+
+
+ 1. Return *true*.
+
FunctionDeclaration :
`function` BindingIdentifier `(` FormalParameters `)` `{` FunctionBody `}`
@@ -7720,6 +8035,124 @@ Static Semantics: IsConstantDeclaration ( ): a Boolean
+
+ Static Semantics: IsUsingDeclaration ( ): a Boolean
+
+ LexicalDeclaration : LetOrConst BindingList `;`
+
+ 1. Return *false*.
+
+
+ UsingDeclaration :
+ `using` BindingList `;`
+
+ AwaitUsingDeclaration :
+ CoverAwaitExpressionAndAwaitUsingDeclarationHead BindingList `;`
+
+
+ 1. Return *true*.
+
+ ForDeclaration : LetOrConst ForBinding
+
+ 1. Return *false*.
+
+
+ ForDeclaration :
+ `using` ForBinding
+ `await` `using` ForBinding
+
+
+ 1. Return *true*.
+
+
+ FunctionDeclaration :
+ `function` BindingIdentifier `(` FormalParameters `)` `{` FunctionBody `}`
+ `function` `(` FormalParameters `)` `{` FunctionBody `}`
+
+ GeneratorDeclaration :
+ `function` `*` BindingIdentifier `(` FormalParameters `)` `{` GeneratorBody `}`
+ `function` `*` `(` FormalParameters `)` `{` GeneratorBody `}`
+
+ AsyncGeneratorDeclaration :
+ `async` `function` `*` BindingIdentifier `(` FormalParameters `)` `{` AsyncGeneratorBody `}`
+ `async` `function` `*` `(` FormalParameters `)` `{` AsyncGeneratorBody `}`
+
+ AsyncFunctionDeclaration :
+ `async` `function` BindingIdentifier `(` FormalParameters `)` `{` AsyncFunctionBody `}`
+ `async` `function` `(` FormalParameters `)` `{` AsyncFunctionBody `}`
+
+
+ 1. Return *false*.
+
+
+ ClassDeclaration :
+ `class` BindingIdentifier ClassTail
+ `class` ClassTail
+
+
+ 1. Return *false*.
+
+
+
+
+ Static Semantics: IsAwaitUsingDeclaration ( ): a Boolean
+
+ LexicalDeclaration : LetOrConst BindingList `;`
+
+ 1. Return *false*.
+
+ UsingDeclaration : `using` BindingList `;`
+
+ 1. Return *false*.
+
+ AwaitUsingDeclaration : CoverAwaitExpressionAndAwaitUsingDeclarationHead BindingList `;`
+
+ 1. Return *true*.
+
+ ForDeclaration : LetOrConst ForBinding
+
+ 1. Return *false*.
+
+ ForDeclaration : `using` ForBinding
+
+ 1. Return *false*.
+
+ ForDeclaration : `await` `using` ForBinding
+
+ 1. Return *true*.
+
+
+ FunctionDeclaration :
+ `function` BindingIdentifier `(` FormalParameters `)` `{` FunctionBody `}`
+ `function` `(` FormalParameters `)` `{` FunctionBody `}`
+
+ GeneratorDeclaration :
+ `function` `*` BindingIdentifier `(` FormalParameters `)` `{` GeneratorBody `}`
+ `function` `*` `(` FormalParameters `)` `{` GeneratorBody `}`
+
+ AsyncGeneratorDeclaration :
+ `async` `function` `*` BindingIdentifier `(` FormalParameters `)` `{` AsyncGeneratorBody `}`
+ `async` `function` `*` `(` FormalParameters `)` `{` AsyncGeneratorBody `}`
+
+ AsyncFunctionDeclaration :
+ `async` `function` BindingIdentifier `(` FormalParameters `)` `{` AsyncFunctionBody `}`
+ `async` `function` `(` FormalParameters `)` `{` AsyncFunctionBody `}`
+
+
+ 1. Return *false*.
+
+
+ ClassDeclaration :
+ `class` BindingIdentifier ClassTail
+ `class` ClassTail
+
+
+ 1. Return *false*.
+
+
+
Static Semantics: LexicallyDeclaredNames ( ): a List of Strings
+
+
+ Static Semantics: ContainsUsing ( ): a Boolean
+
+ StatementList : StatementList StatementListItem
+
+ 1. If ContainsUsing of the derived |StatementList| is *true*, return *true*.
+ 1. If ContainsUsing of |StatementListItem| is *true*, return *true*.
+ 1. Return *false*.
+
+ StatementListItem : Statement
+
+ 1. Return *false*.
+
+ StatementListItem : Declaration
+
+ 1. If IsUsingDeclaration of |Declaration| is *true*, return *true*.
+ 1. If IsAwaitUsingDeclaration of |Declaration| is *true*, return *true*.
+ 1. Return *false*.
+
+
@@ -10343,6 +10798,7 @@ The Environment Record Type Hierarchy
Declarative Environment Records
Each Declarative Environment Record is associated with an ECMAScript program scope containing variable, constant, let, class, module, import, and/or function declarations. A Declarative Environment Record binds the set of identifiers defined by the declarations contained within its scope.
+ Every Declarative Environment Record also has a [[DisposeCapability]] field, which contains a DisposeCapability Record. This field holds a stack of resources tracked by the `using` declarations and `await using` declarations that must be disposed when the Evaluation step that constructed the Environment Record has completed.
@@ -11463,6 +11919,7 @@
1. Let _env_ be a new Declarative Environment Record containing no bindings.
1. Set _env_.[[OuterEnv]] to _outerEnv_.
+ 1. Set _env_.[[DisposeCapability]] to NewDisposeCapability().
1. Return _env_.
@@ -11502,6 +11959,7 @@
1. Else, set _env_.[[ThisBindingStatus]] to ~uninitialized~.
1. Set _env_.[[NewTarget]] to _newTarget_.
1. Set _env_.[[OuterEnv]] to _func_.[[Environment]].
+ 1. Set _env_.[[DisposeCapability]] to NewDisposeCapability().
1. Return _env_.
@@ -11538,6 +11996,7 @@
1. Let _env_ be a new Module Environment Record containing no bindings.
1. Set _env_.[[OuterEnv]] to _outerEnv_.
+ 1. Set _env_.[[DisposeCapability]] to NewDisposeCapability().
1. Return _env_.
@@ -16832,7 +17291,7 @@ Static Semantics: IdentifierCodePoint ( ): a code point
Keywords and Reserved Words
A keyword is a token that matches |IdentifierName|, but also has a syntactic use; that is, it appears literally, in a `fixed width` font, in some syntactic production. The keywords of ECMAScript include `if`, `while`, `async`, `await`, and many others.
A reserved word is an |IdentifierName| that cannot be used as an identifier. Many keywords are reserved words, but some are not, and some are reserved only in certain contexts. `if` and `while` are reserved words. `await` is reserved only inside async functions and modules. `async` is not reserved; it can be used as a variable name or statement label without restriction.
- This specification uses a combination of grammatical productions and early error rules to specify which names are valid identifiers and which are reserved words. All tokens in the |ReservedWord| list below, except for `await` and `yield`, are unconditionally reserved. Exceptions for `await` and `yield` are specified in , using parameterized syntactic productions. Lastly, several early error rules restrict the set of valid identifiers. See , , , and . In summary, there are five categories of identifier names:
+ This specification uses a combination of grammatical productions and early error rules to specify which names are valid identifiers and which are reserved words. All tokens in the |ReservedWord| list below, except for `await` and `yield`, are unconditionally reserved. Exceptions for `await` and `yield` are specified in , using parameterized syntactic productions. Lastly, several early error rules restrict the set of valid identifiers. See , , , and . In summary, there are five categories of identifier names:
-
Those that are always allowed as identifiers, and are not keywords, such as `Math`, `window`, `toString`, and `_`;
@@ -17959,6 +18418,9 @@ Rules of Automatic Semicolon Insertion
LeftHandSideExpression[?Yield, ?Await] [no LineTerminator here] `++`
LeftHandSideExpression[?Yield, ?Await] [no LineTerminator here] `--`
+ UsingDeclaration[In, Yield, Await] :
+ `using` [no LineTerminator here] BindingList[?In, ?Yield, ?Await, ~Pattern] `;`
+
ContinueStatement[Yield, Await] :
`continue` `;`
`continue` [no LineTerminator here] LabelIdentifier[?Yield, ?Await] `;`
@@ -18014,6 +18476,9 @@ Rules of Automatic Semicolon Insertion
-
When a `++` or `--` token is encountered where the parser would treat it as a postfix operator, and at least one |LineTerminator| occurred between the preceding token and the `++` or `--` token, then a semicolon is automatically inserted before the `++` or `--` token.
+ -
+ When a `using` token is encountered and a |LineTerminator| is encountered before an |IdentifierName| token, a semicolon is automatically inserted after the `using` token.
+
-
When a `continue`, `break`, `return`, `throw`, or `yield` token is encountered and a |LineTerminator| is encountered before the next token, a semicolon is automatically inserted after the `continue`, `break`, `return`, `throw`, or `yield` token.
@@ -18032,6 +18497,9 @@ Rules of Automatic Semicolon Insertion
-
A postfix `++` or `--` operator should be on the same line as its operand.
+ -
+ A |BindingList| in a `using` declaration should start on the same line as the `using` token.
+
-
An |Expression| in a `return` or `throw` statement or an |AssignmentExpression| in a `yield` expression should start on the same line as the `return`, `throw`, or `yield` token.
@@ -20078,7 +20546,21 @@ Syntax
`-` UnaryExpression[?Yield, ?Await]
`~` UnaryExpression[?Yield, ?Await]
`!` UnaryExpression[?Yield, ?Await]
- [+Await] AwaitExpression[?Yield]
+ [+Await] CoverAwaitExpressionAndAwaitUsingDeclarationHead[?Yield] #awaitusingcover
+
+ CoverAwaitExpressionAndAwaitUsingDeclarationHead[Yield] :
+ `await` UnaryExpression[?Yield, +Await]
+
+
+ Supplemental Syntax
+
+ When processing an instance of the production
+ UnaryExpression : CoverAwaitExpressionAndAwaitUsingDeclarationHead
+ the interpretation of |CoverAwaitExpressionAndAwaitUsingDeclarationHead| is refined using the following grammar:
+
+
+ AwaitExpression[Yield] :
+ `await` UnaryExpression[?Yield, +Await]
@@ -21444,6 +21926,7 @@ Runtime Semantics: Evaluation
1. Perform BlockDeclarationInstantiation(|StatementList|, _blockEnv_).
1. Set the running execution context's LexicalEnvironment to _blockEnv_.
1. Let _blockValue_ be Completion(Evaluation of |StatementList|).
+ 1. Set _blockValue_ to Completion(DisposeResources(_blockEnv_.[[DisposeCapability]], _blockValue_)).
1. Set the running execution context's LexicalEnvironment to _oldEnv_.
1. Return ? _blockValue_.
@@ -21513,30 +21996,49 @@
Declarations and the Variable Statement
-
- Let and Const Declarations
+
+ Let, Const, Using, and Await Using Declarations
- `let` and `const` declarations define variables that are scoped to the running execution context's LexicalEnvironment. The variables are created when their containing Environment Record is instantiated but may not be accessed in any way until the variable's |LexicalBinding| is evaluated. A variable defined by a |LexicalBinding| with an |Initializer| is assigned the value of its |Initializer|'s |AssignmentExpression| when the |LexicalBinding| is evaluated, not when the variable is created. If a |LexicalBinding| in a `let` declaration does not have an |Initializer| the variable is assigned the value *undefined* when the |LexicalBinding| is evaluated.
+ `let`, `const`, `using`, and `await using` declarations define variables that are scoped to the running execution context's LexicalEnvironment. The variables are created when their containing Environment Record is instantiated but may not be accessed in any way until the variable's |LexicalBinding| is evaluated. A variable defined by a |LexicalBinding| with an |Initializer| is assigned the value of its |Initializer|'s |AssignmentExpression| when the |LexicalBinding| is evaluated, not when the variable is created. If a |LexicalBinding| in a `let` declaration does not have an |Initializer| the variable is assigned the value *undefined* when the |LexicalBinding| is evaluated.
Syntax
LexicalDeclaration[In, Yield, Await] :
- LetOrConst BindingList[?In, ?Yield, ?Await] `;`
+ LetOrConst BindingList[?In, ?Yield, ?Await, +Pattern] `;`
+ UsingDeclaration[?In, ?Yield, ?Await]
+ [+Await] AwaitUsingDeclaration[?In, ?Yield]
LetOrConst :
`let`
`const`
- BindingList[In, Yield, Await] :
- LexicalBinding[?In, ?Yield, ?Await]
- BindingList[?In, ?Yield, ?Await] `,` LexicalBinding[?In, ?Yield, ?Await]
+ UsingDeclaration[In, Yield, Await] :
+ `using` [no LineTerminator here] BindingList[?In, ?Yield, ?Await, ~Pattern] `;`
- LexicalBinding[In, Yield, Await] :
+ 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]?
- BindingPattern[?Yield, ?Await] Initializer[?In, ?Yield, ?Await]
+ [+Pattern] BindingPattern[?Yield, ?Await] Initializer[?In, ?Yield, ?Await]
-
+ Supplemental Syntax
+
+ When processing an instance of the production
+ AwaitUsingDeclaration : CoverAwaitExpressionAndAwaitUsingDeclarationHead BindingList `;`
+ the interpretation of |CoverAwaitExpressionAndAwaitUsingDeclarationHead| is refined using the following grammar:
+
+
+ AwaitUsingDeclarationHead :
+ `await` [no LineTerminator here] `using`
+
+
+
Static Semantics: Early Errors
LexicalDeclaration : LetOrConst BindingList `;`
@@ -21547,6 +22049,31 @@ Static Semantics: Early Errors
It is a Syntax Error if the BoundNames of |BindingList| contains any duplicate entries.
+
+ UsingDeclaration :
+ `using` BindingList `;`
+
+
+ -
+ It is a Syntax Error if the BoundNames of |BindingList| contains *"let"*.
+
+ -
+ It is a Syntax Error if the BoundNames of |BindingList| contains any duplicate entries.
+
+
+
+ AwaitUsingDeclaration :
+ CoverAwaitExpressionAndAwaitUsingDeclarationHead BindingList `;`
+
+
+ - |CoverAwaitExpressionAndAwaitUsingDeclarationHead| must cover an |AwaitUsingDeclarationHead|.
+ -
+ It is a Syntax Error if the BoundNames of |BindingList| contains *"let"*.
+
+ -
+ It is a Syntax Error if the BoundNames of |BindingList| contains any duplicate entries.
+
+
LexicalBinding : BindingIdentifier Initializer?
-
@@ -21555,26 +22082,47 @@
Static Semantics: Early Errors
-
+
Runtime Semantics: Evaluation
LexicalDeclaration : LetOrConst BindingList `;`
- 1. Perform ? Evaluation of |BindingList|.
+ 1. Perform ? BindingEvaluation of |BindingList| with argument ~normal~.
+ 1. Return ~empty~.
+
+ UsingDeclaration : `using` BindingList `;`
+
+ 1. Perform ? BindingEvaluation of |BindingList| with argument ~sync-dispose~.
1. Return ~empty~.
+ AwaitUsingDeclaration : CoverAwaitExpressionAndAwaitUsingDeclarationHead BindingList `;`
+
+ 1. Perform ? BindingEvaluation of |BindingList| with argument ~async-dispose~.
+ 1. Return ~empty~.
+
+
+
+
+
+ Runtime Semantics: BindingEvaluation (
+ _kind_: ~normal~, ~sync-dispose~, or ~async-dispose~,
+ ): either a normal completion containing ~unused~ or an abrupt completion
+
+
BindingList : BindingList `,` LexicalBinding
- 1. Perform ? Evaluation of |BindingList|.
- 1. Return ? Evaluation of |LexicalBinding|.
+ 1. Perform ? BindingEvaluation of the derived |BindingList| with argument _kind_.
+ 1. Return ? BindingEvaluation of |LexicalBinding| with argument _kind_.
LexicalBinding : BindingIdentifier
+ 1. Assert: _kind_ is ~normal~.
1. Let _lhs_ be ! ResolveBinding(StringValue of |BindingIdentifier|).
1. Perform ! InitializeReferencedBinding(_lhs_, *undefined*).
- 1. Return ~empty~.
+ 1. Return ~unused~.
- A static semantics rule ensures that this form of |LexicalBinding| never occurs in a `const` declaration.
+ A static semantics rule ensures that this form of |LexicalBinding| never occurs in a `const`, `using`, or `await using` declaration.
LexicalBinding : BindingIdentifier Initializer
@@ -21585,11 +22133,17 @@ Runtime Semantics: Evaluation
1. Else,
1. Let _rhs_ be ? Evaluation of |Initializer|.
1. Let _value_ be ? GetValue(_rhs_).
- 1. Perform ! InitializeReferencedBinding(_lhs_, _value_).
- 1. Return ~empty~.
+ 1. If _kind_ is not ~normal~, then
+ 1. Assert: IsUnresolvableReference(_lhs_) is *false*.
+ 1. Let _base_ be _lhs_.[[Base]].
+ 1. Assert: _base_ is a Declarative Environment Record.
+ 1. Perform ? AddDisposableResource(_base_.[[DisposeCapability]], _value_, _kind_).
+ 1. Perform ? InitializeReferencedBinding(_lhs_, _value_).
+ 1. Return ~unused~.
LexicalBinding : BindingPattern Initializer
+ 1. Assert: _kind_ is ~normal~.
1. Let _rhs_ be ? Evaluation of |Initializer|.
1. Let _value_ be ? GetValue(_rhs_).
1. Let _env_ be the running execution context's LexicalEnvironment.
@@ -22111,12 +22665,16 @@
1. Set the running execution context's LexicalEnvironment to _loopEnv_.
1. Let _forDcl_ be Completion(Evaluation of |LexicalDeclaration|).
1. If _forDcl_ is an abrupt completion, then
+ 1. Set _forDcl_ to Completion(DisposeResources(_loopEnv_.[[DisposeCapability]], _forDcl_)).
+ 1. Assert: _forDcl_ is an abrupt completion.
1. Set the running execution context's LexicalEnvironment to _oldEnv_.
1. Return ? _forDcl_.
1. If _isConst_ is *false*, let _perIterationLets_ be _boundNames_; else let _perIterationLets_ be a new empty List.
1. If the first |Expression| is present, let _test_ be the first |Expression|; else let _test_ be ~empty~.
1. If the second |Expression| is present, let _increment_ be the second |Expression|; else let _increment_ be ~empty~.
1. Let _bodyResult_ be Completion(ForBodyEvaluation(_test_, _increment_, |Statement|, _perIterationLets_, _labelSet_)).
+ 1. Set _bodyResult_ to Completion(DisposeResources(_loopEnv_.[[DisposeCapability]], _bodyResult_)).
+ 1. Assert: If _bodyResult_.[[Type]] is ~normal~, then _bodyResult_.[[Value]] is not ~empty~.
1. Set the running execution context's LexicalEnvironment to _oldEnv_.
1. Return ? _bodyResult_.
@@ -22182,21 +22740,23 @@ Syntax
ForInOfStatement[Yield, Await, Return] :
`for` `(` [lookahead != `let` `[`] LeftHandSideExpression[?Yield, ?Await] `in` Expression[+In, ?Yield, ?Await] `)` Statement[?Yield, ?Await, ?Return]
- `for` `(` `var` ForBinding[?Yield, ?Await] `in` Expression[+In, ?Yield, ?Await] `)` Statement[?Yield, ?Await, ?Return]
- `for` `(` ForDeclaration[?Yield, ?Await] `in` Expression[+In, ?Yield, ?Await] `)` Statement[?Yield, ?Await, ?Return]
+ `for` `(` `var` ForBinding[?Yield, ?Await, +Pattern] `in` Expression[+In, ?Yield, ?Await] `)` Statement[?Yield, ?Await, ?Return]
+ `for` `(` ForDeclaration[?Yield, ?Await, ~Using] `in` Expression[+In, ?Yield, ?Await] `)` Statement[?Yield, ?Await, ?Return]
`for` `(` [lookahead ∉ { `let`, `async` `of` }] LeftHandSideExpression[?Yield, ?Await] `of` AssignmentExpression[+In, ?Yield, ?Await] `)` Statement[?Yield, ?Await, ?Return]
- `for` `(` `var` ForBinding[?Yield, ?Await] `of` AssignmentExpression[+In, ?Yield, ?Await] `)` Statement[?Yield, ?Await, ?Return]
- `for` `(` ForDeclaration[?Yield, ?Await] `of` AssignmentExpression[+In, ?Yield, ?Await] `)` Statement[?Yield, ?Await, ?Return]
+ `for` `(` `var` ForBinding[?Yield, ?Await, +Pattern] `of` AssignmentExpression[+In, ?Yield, ?Await] `)` Statement[?Yield, ?Await, ?Return]
+ `for` `(` [lookahead != `using` `of`] ForDeclaration[?Yield, ?Await, +Using] `of` AssignmentExpression[+In, ?Yield, ?Await] `)` Statement[?Yield, ?Await, ?Return]
[+Await] `for` `await` `(` [lookahead != `let`] LeftHandSideExpression[?Yield, ?Await] `of` AssignmentExpression[+In, ?Yield, ?Await] `)` Statement[?Yield, ?Await, ?Return]
- [+Await] `for` `await` `(` `var` ForBinding[?Yield, ?Await] `of` AssignmentExpression[+In, ?Yield, ?Await] `)` Statement[?Yield, ?Await, ?Return]
- [+Await] `for` `await` `(` ForDeclaration[?Yield, ?Await] `of` AssignmentExpression[+In, ?Yield, ?Await] `)` Statement[?Yield, ?Await, ?Return]
+ [+Await] `for` `await` `(` `var` ForBinding[?Yield, ?Await, +Pattern] `of` AssignmentExpression[+In, ?Yield, ?Await] `)` Statement[?Yield, ?Await, ?Return]
+ [+Await] `for` `await` `(` [lookahead != `using` `of`] ForDeclaration[?Yield, ?Await, +Using] `of` AssignmentExpression[+In, ?Yield, ?Await] `)` Statement[?Yield, ?Await, ?Return]
- ForDeclaration[Yield, Await] :
- LetOrConst ForBinding[?Yield, ?Await]
+ ForDeclaration[Yield, Await, Using] :
+ LetOrConst ForBinding[?Yield, ?Await, +Pattern]
+ [+Using] `using` [no LineTerminator here] ForBinding[?Yield, ?Await, ~Pattern]
+ [+Using, +Await] `await` [no LineTerminator here] `using` [no LineTerminator here] ForBinding[?Yield, +Await, ~Pattern]
- ForBinding[Yield, Await] :
+ ForBinding[Yield, Await, Pattern] :
BindingIdentifier[?Yield, ?Await]
- BindingPattern[?Yield, ?Await]
+ [+Pattern] BindingPattern[?Yield, ?Await]
This section is extended by Annex .
@@ -22316,6 +22876,14 @@
1. Return ? BindingInitialization of |ForBinding| with arguments _value_ and _environment_.
+
+ ForDeclaration :
+ `using` ForBinding
+ `await` `using` ForBinding
+
+
+ 1. Throw a *SyntaxError* exception.
+
@@ -22335,6 +22903,16 @@
1. Perform ! _environment_.CreateMutableBinding(_name_, *false*).
1. Return ~unused~.
+
+ ForDeclaration :
+ `using` ForBinding
+ `await` `using` ForBinding
+
+
+ 1. For each element _name_ of the BoundNames of |ForBinding|, do
+ 1. Perform ! _environment_.CreateImmutableBinding(_name_, *true*).
+ 1. Return ~unused~.
+
@@ -22454,6 +23032,16 @@
1. If _iteratorKind_ is not present, set _iteratorKind_ to ~sync~.
1. Let _oldEnv_ be the running execution context's LexicalEnvironment.
1. Let _iterationResult_ be *undefined*.
+ 1. If _lhsKind_ is ~lexical-binding~, then
+ 1. Assert: _lhs_ is a |ForDeclaration|.
+ 1. If IsAwaitUsingDeclaration of _lhs_ is *true*, then
+ 1. Let _declarationKind_ be ~async-dispose~.
+ 1. Else if IsUsingDeclaration of _lhs_ is *true*, then
+ 1. Let _declarationKind_ be ~sync-dispose~.
+ 1. Else,
+ 1. Let _declarationKind_ be ~normal~.
+ 1. Else,
+ 1. Let _declarationKind_ be ~normal~.
1. Let _destructuring_ be IsDestructuring of _lhs_.
1. If _destructuring_ is *true* and _lhsKind_ is ~assignment~, then
1. Assert: _lhs_ is a |LeftHandSideExpression|.
@@ -22480,6 +23068,7 @@
1. Let _status_ be _lhsRef_.
1. Else,
1. Let _status_ be Completion(PutValue(_lhsRef_.[[Value]], _nextValue_)).
+ 1. Let _iterationEnv_ be *undefined*.
1. Else,
1. Assert: _lhsKind_ is ~lexical-binding~.
1. Assert: _lhs_ is a |ForDeclaration|.
@@ -22492,14 +23081,27 @@
1. Assert: _lhs_ binds a single name.
1. Let _lhsName_ be the sole element of the BoundNames of _lhs_.
1. Let _lhsRef_ be ! ResolveBinding(_lhsName_).
- 1. Let _status_ be Completion(InitializeReferencedBinding(_lhsRef_, _nextValue_)).
+ 1. If _declarationKind_ is not ~normal~, then
+ 1. Assert: IsUnresolvableReference(_lhsRef_) is *false*.
+ 1. Let _base_ be _lhsRef_.[[Base]].
+ 1. Assert: _base_ is a Declarative Environment Record.
+ 1. Let _status_ be Completion(AddDisposableResource(_base_.[[DisposeCapability]], _nextValue_, _declarationKind_)).
+ 1. Else,
+ 1. Let _status_ be NormalCompletion(~unused~).
+ 1. If _status_ is a normal completion, then
+ 1. Set _status_ to Completion(InitializeReferencedBinding(_lhsRef_, _nextValue_)).
1. If _status_ is an abrupt completion, then
+ 1. If _iterationEnv_ is not *undefined*, then
+ 1. Set _status_ to Completion(DisposeResources(_iterationEnv_.[[DisposeCapability]], _status_)).
+ 1. Assert: _status_ is an abrupt completion.
1. Set the running execution context's LexicalEnvironment to _oldEnv_.
1. If _iterationKind_ is ~enumerate~, return ? _status_.
1. Assert: _iterationKind_ is ~iterate~.
1. If _iteratorKind_ is ~async~, return ? AsyncIteratorClose(_iteratorRecord_, _status_).
1. Return ? IteratorClose(_iteratorRecord_, _status_).
1. Let _result_ be Completion(Evaluation of _stmt_).
+ 1. If _iterationEnv_ is not *undefined*, then
+ 1. Set _result_ to Completion(DisposeResources(_iterationEnv_.[[DisposeCapability]], _result_)).
1. Set the running execution context's LexicalEnvironment to _oldEnv_.
1. If LoopContinues(_result_, _labelSet_) is *false*, then
1. Set _status_ to Completion(UpdateEmpty(_result_, _iterationResult_)).
@@ -22892,6 +23494,18 @@ Static Semantics: Early Errors
It is a Syntax Error if any element of the LexicallyDeclaredNames of |CaseBlock| also occurs in the VarDeclaredNames of |CaseBlock|.
+ CaseClause : `case` Expression `:` StatementList
+
+ -
+ It is a Syntax Error if ContainsUsing of |StatementList| is *true*.
+
+
+ DefaultClause : `default` `:` StatementList
+
+ -
+ It is a Syntax Error if ContainsUsing of |StatementList| is *true*.
+
+
@@ -22994,6 +23608,7 @@ Runtime Semantics: Evaluation
1. Perform BlockDeclarationInstantiation(|CaseBlock|, _blockEnv_).
1. Set the running execution context's LexicalEnvironment to _blockEnv_.
1. Let _blockResult_ be Completion(CaseBlockEvaluation of |CaseBlock| with argument _switchValue_).
+ 1. Assert: _blockEnv_.[[DisposeCapability]] is an empty List.
1. Set the running execution context's LexicalEnvironment to _oldEnv_.
1. Return _blockResult_.
@@ -23782,6 +24397,13 @@ Runtime Semantics: Evaluation
1. Return *undefined*.
+ FunctionStatementList : StatementList
+
+ 1. Let _result_ be Completion(Evaluation of |StatementList|).
+ 1. Let _env_ be the running execution context's LexicalEnvironment.
+ 1. Assert: _env_ is a Declarative Environment Record.
+ 1. Return ? DisposeResources(_env_.[[DisposeCapability]], _result_).
+
@@ -25071,7 +25693,10 @@
1. Assert: _functionObject_ is a synthetic function created by ClassStaticBlockDefinitionEvaluation step .
1. Perform ! FunctionDeclarationInstantiation(_functionObject_, « »).
- 1. Perform ? Evaluation of |ClassStaticBlockStatementList|.
+ 1. Let _result_ be Completion(Evaluation of |ClassStaticBlockStatementList|).
+ 1. Let _env_ be the running execution context's LexicalEnvironment.
+ 1. Assert: _env_ is a Declarative Environment Record.
+ 1. Perform ? DisposeResources(_env_.[[DisposeCapability]], _result_).
1. Return ReturnCompletion(*undefined*).
@@ -25483,6 +26108,13 @@ Runtime Semantics: Evaluation
1. Return InstantiateAsyncFunctionExpression of |AsyncFunctionExpression|.
+
+ UnaryExpression : CoverAwaitExpressionAndAwaitUsingDeclarationHead
+
+
+ 1. Let _expr_ be the |AwaitExpression| that is covered by |CoverAwaitExpressionAndAwaitUsingDeclarationHead|.
+ 1. Return ? Evaluation of _expr_.
+
AwaitExpression : `await` UnaryExpression
@@ -25671,11 +26303,15 @@
A potential tail position call that is immediately followed by return GetValue of the call result is also a possible tail position call. A function call cannot return a Reference Record, so such a GetValue operation will always return the same value as the actual function call result.
+
+ A `using` declaration or `await using` declaration that precedes a call in the same |Block|, |ForStatement|, |ForInOfStatement|, |FunctionBody|, |GeneratorBody|, |AsyncGeneratorBody|, |AsyncFunctionBody|, or |ClassStaticBlockBody| prevents that call from being a possible tail position call.
+
StatementList : StatementList StatementListItem
- 1. Let _has_ be HasCallInTailPosition of |StatementList| with argument _call_.
+ 1. Let _has_ be HasCallInTailPosition of the derived |StatementList| with argument _call_.
1. If _has_ is *true*, return *true*.
+ 1. If ContainsUsing of the derived |StatementList| is *true*, return *false*.
1. Return HasCallInTailPosition of |StatementListItem| with argument _call_.
@@ -25867,7 +26503,7 @@
`-` UnaryExpression
`~` UnaryExpression
`!` UnaryExpression
- AwaitExpression
+ CoverAwaitExpressionAndAwaitUsingDeclarationHead
CallExpression :
SuperCall
@@ -26054,6 +26690,9 @@ Static Semantics: Early Errors
It is a Syntax Error if AllPrivateIdentifiersValid of |StatementList| with argument « » is *false* unless the source text containing |ScriptBody| is eval code that is being processed by a direct eval.
+
+ It is a Syntax Error if ContainsUsing of |StatementList| is *true*.
+
@@ -28680,11 +29319,13 @@
1. Assert: _module_ has been linked and declarations in its module environment have been instantiated.
1. Let _moduleContext_ be _module_.[[Context]].
+ 1. Let _env_ be _module_.[[Environment]].
1. Suspend the running execution context.
1. If _module_.[[HasTLA]] is *false*, then
1. Assert: _capability_ is not present.
1. Push _moduleContext_ onto the execution context stack; _moduleContext_ is now the running execution context.
1. Let _result_ be Completion(Evaluation of _module_.[[ECMAScriptCode]]).
+ 1. Set _result_ to Completion(DisposeResources(_env_.[[DisposeCapability]], _result_)).
1. Suspend _moduleContext_ and remove it from the execution context stack.
1. Resume the context that is now on the top of the execution context stack as the running execution context.
1. If _result_ is an abrupt completion, then
@@ -29297,7 +29938,7 @@ Syntax
`export` ExportFromClause FromClause WithClause? `;`
`export` NamedExports `;`
`export` VariableStatement[~Yield, +Await]
- `export` Declaration[~Yield, +Await]
+ `export` [lookahead ∉ { `using`, `await` }] Declaration[~Yield, +Await]
`export` `default` HoistableDeclaration[~Yield, +Await, +Default]
`export` `default` ClassDeclaration[~Yield, +Await, +Default]
`export` `default` [lookahead ∉ { `function`, `async` [no LineTerminator here] `function`, `class` }] AssignmentExpression[+In, ~Yield, +Await] `;`
@@ -30315,6 +30956,11 @@ ArrayBuffer ( . . . )
See .
+
+ AsyncDisposableStack ( . . . )
+ See .
+
+
BigInt ( . . . )
See .
@@ -30345,6 +30991,11 @@ Date ( . . . )
See .
+
+ DisposableStack ( . . . )
+ See .
+
+
Error ( . . . )
See .
@@ -30455,6 +31106,11 @@ String ( . . . )
See .
+
+ SuppressedError ( . . . )
+ See .
+
+
Symbol ( . . . )
See .
@@ -31835,7 +32491,7 @@
Error Objects
Instances of Error objects are thrown as exceptions when runtime errors occur. The Error objects may also serve as base objects for user-defined exception classes.
- When an ECMAScript implementation detects a runtime error, it throws a new instance of one of the _NativeError_ objects defined in or a new instance of the AggregateError object defined in .
+ When an ECMAScript implementation detects a runtime error, it throws a new instance of one of the _NativeError_ objects defined in or a new instance of either the AggregateError object defined in , or the SuppressedError object defined in . Each of these objects has the structure described below, differing only in the name used as the constructor name instead of _NativeError_, in the *"name"* property of the prototype object, in the implementation-defined *"message"* property of the prototype object, and in the presence of the %AggregateError%-specific *"errors"* property or the %SuppressedError%-specific *"error"* and *"suppressed"* properties.
The Error Constructor
@@ -31931,12 +32587,12 @@ Error.prototype.toString ( )
Properties of Error Instances
- Error instances are ordinary objects that inherit properties from the Error prototype object and have an [[ErrorData]] internal slot whose value is *undefined*. The only specified use of [[ErrorData]] is to identify Error, AggregateError, and _NativeError_ instances as Error objects within `Object.prototype.toString` and `Error.isError`.
+ Error instances are ordinary objects that inherit properties from the Error prototype object and have an [[ErrorData]] internal slot whose value is *undefined*. The only specified use of [[ErrorData]] is to identify Error, AggregateError, SuppressedError, and _NativeError_ instances as Error objects within `Object.prototype.toString` and `Error.isError`.
Native Error Types Used in This Standard
- A new instance of one of the _NativeError_ objects below or of the AggregateError object is thrown when a runtime error is detected. All _NativeError_ objects share the same structure, as described in .
+ A new instance of one of the _NativeError_ objects below or of either the AggregateError object or SuppressedError object is thrown when a runtime error is detected. All _NativeError_ objects share the same structure, as described in .
EvalError
@@ -32047,7 +32703,7 @@ _NativeError_.prototype.name
Properties of _NativeError_ Instances
- _NativeError_ instances are ordinary objects that inherit properties from their _NativeError_ prototype object and have an [[ErrorData]] internal slot whose value is *undefined*. The only specified use of [[ErrorData]] is by `Object.prototype.toString` () and `Error.isError` () to identify Error, AggregateError, or _NativeError_ instances.
+ _NativeError_ instances are ordinary objects that inherit properties from their _NativeError_ prototype object and have an [[ErrorData]] internal slot whose value is *undefined*. The only specified use of [[ErrorData]] is by `Object.prototype.toString` () and `Error.isError` () to identify Error, AggregateError, SuppressedError, or _NativeError_ instances.
@@ -32124,7 +32780,83 @@ AggregateError.prototype.name
Properties of AggregateError Instances
- AggregateError instances are ordinary objects that inherit properties from their AggregateError prototype object and have an [[ErrorData]] internal slot whose value is *undefined*. The only specified use of [[ErrorData]] is by `Object.prototype.toString` () and `Error.isError` () to identify Error, AggregateError, or _NativeError_ instances.
+ AggregateError instances are ordinary objects that inherit properties from their AggregateError prototype object and have an [[ErrorData]] internal slot whose value is *undefined*. The only specified use of [[ErrorData]] is by `Object.prototype.toString` () and `Error.isError` () to identify Error, AggregateError, SuppressedError, or _NativeError_ instances.
+
+
+
+
+ SuppressedError Objects
+
+
+ The SuppressedError Constructor
+ The SuppressedError constructor:
+
+ - is %SuppressedError%.
+ - is the initial value of the *"SuppressedError"* property of the global object.
+ - creates and initializes a new SuppressedError object when called as a function rather than as a constructor. Thus the function call `SuppressedError(…)` is equivalent to the object creation expression `new SuppressedError(…)` with the same arguments.
+ - may be used as the value of an `extends` clause of a class definition. Subclass constructors that intend to inherit the specified SuppressedError behaviour must include a `super` call to the SuppressedError constructor to create and initialize subclass instances with an [[ErrorData]] internal slot.
+
+
+
+ SuppressedError ( _error_, _suppressed_, _message_ )
+ This function performs the following steps when called:
+
+ 1. If NewTarget is *undefined*, let _newTarget_ be the active function object; else let _newTarget_ be NewTarget.
+ 1. Let _obj_ be ? OrdinaryCreateFromConstructor(_newTarget_, *"%SuppressedError.prototype%"*, « [[ErrorData]] »).
+ 1. If _message_ is not *undefined*, then
+ 1. Let _messageString_ be ? ToString(_message_).
+ 1. Perform CreateNonEnumerableDataPropertyOrThrow(_obj_, *"message"*, _messageString_).
+ 1. Perform CreateNonEnumerableDataPropertyOrThrow(_obj_, *"error"*, _error_).
+ 1. Perform CreateNonEnumerableDataPropertyOrThrow(_obj_, *"suppressed"*, _suppressed_).
+ 1. Return _obj_.
+
+
+
+
+
+ Properties of the SuppressedError Constructor
+ The SuppressedError constructor:
+
+ - has a [[Prototype]] internal slot whose value is %Error%.
+ - has the following properties:
+
+
+
+ SuppressedError.prototype
+ The initial value of `SuppressedError.prototype` is %SuppressedError.prototype%.
+ This property has the attributes { [[Writable]]: *false*, [[Enumerable]]: *false*, [[Configurable]]: *false* }.
+
+
+
+
+ Properties of the SuppressedError Prototype Object
+ The SuppressedError prototype object:
+
+ - is %SuppressedError.prototype%.
+ - is an ordinary object.
+ - is not an Error instance or an SuppressedError instance and does not have an [[ErrorData]] internal slot.
+ - has a [[Prototype]] internal slot whose value is %Error.prototype%.
+
+
+
+ SuppressedError.prototype.constructor
+ The initial value of `SuppressedError.prototype.constructor` is %SuppressedError%.
+
+
+
+ SuppressedError.prototype.message
+ The initial value of `SuppressedError.prototype.message` is the empty String.
+
+
+
+ SuppressedError.prototype.name
+ The initial value of `SuppressedError.prototype.name` is *"SuppressedError"*.
+
+
+
+
+ Properties of SuppressedError Instances
+ SuppressedError instances are ordinary objects that inherit properties from their SuppressedError prototype object and have an [[ErrorData]] internal slot whose value is *undefined*. The only specified use of [[ErrorData]] is by `Object.prototype.toString` () to identify Error, AggregateError, SuppressedError, or _NativeError_ instances.
@@ -48964,9 +49696,22 @@ Iterator.prototype.toArray ( )
+
+ Iterator.prototype [ %Symbol.dispose% ] ( )
+ This method performs the following steps when called:
+
+ 1. Let _obj_ be the *this* value.
+ 1. Let _return_ be ? GetMethod(_obj_, *"return"*).
+ 1. If _return_ is not *undefined*, then
+ 1. Perform ? Call(_return_, _obj_).
+ 1. Return *undefined*.
+
+ The value of the *"name"* property of this function is *"[Symbol.dispose]"*.
+
+
Iterator.prototype [ %Symbol.iterator% ] ( )
- This function performs the following steps when called:
+ This method performs the following steps when called:
1. Return the *this* value.
@@ -49012,9 +49757,33 @@ The %AsyncIteratorPrototype% Object
All objects defined in this specification that implement the async iterator interface also inherit from %AsyncIteratorPrototype%. ECMAScript code may also define objects that inherit from %AsyncIteratorPrototype%. The %AsyncIteratorPrototype% object provides a place where additional methods that are applicable to all async iterator objects may be added.
+
+ %AsyncIteratorPrototype% [ %Symbol.asyncDispose% ] ( )
+ This method performs the following steps when called:
+
+ 1. Let _obj_ be the *this* value.
+ 1. Let _promiseCapability_ be ! NewPromiseCapability(%Promise%).
+ 1. Let _return_ be Completion(GetMethod(_obj_, *"return"*)).
+ 1. IfAbruptRejectPromise(_return_, _promiseCapability_).
+ 1. If _return_ is *undefined*, then
+ 1. Perform ! Call(_promiseCapability_.[[Resolve]], *undefined*, « *undefined* »).
+ 1. Else,
+ 1. Let _result_ be Completion(Call(_return_, _obj_, « *undefined* »)).
+ 1. IfAbruptRejectPromise(_result_, _promiseCapability_).
+ 1. Let _resultWrapper_ be Completion(PromiseResolve(%Promise%, _result_)).
+ 1. IfAbruptRejectPromise(_resultWrapper_, _promiseCapability_).
+ 1. Let _unwrap_ be a new Abstract Closure with no parameters that captures nothing and performs the following steps when called:
+ 1. Return *undefined*.
+ 1. Let _onFulfilled_ be CreateBuiltinFunction(_unwrap_, 1, *""*, « »).
+ 1. Perform PerformPromiseThen(_resultWrapper_, _onFulfilled_, *undefined*, _promiseCapability_).
+ 1. Return _promiseCapability_.[[Promise]].
+
+ The value of the *"name"* property of this function is *"[Symbol.asyncDispose]"*.
+
+
%AsyncIteratorPrototype% [ %Symbol.asyncIterator% ] ( )
- This function performs the following steps when called:
+ This method performs the following steps when called:
1. Return the *this* value.
@@ -49206,6 +49975,476 @@
+
+ Resource Management
+
+
+ Common Resource Management Interfaces
+
+
+ The Disposable Interface
+ The Disposable interface includes the property described in :
+
+
+
+ |
+ Property
+ |
+
+ Value
+ |
+
+ Requirements
+ |
+
+
+ |
+ `%Symbol.dispose%`
+ |
+
+ a function object
+ |
+
+ Invoking this method notifies the Disposable object that the caller does not intend to continue to use this object. This method should perform any necessary logic to perform explicit clean-up of the resource including, but not limited to, file system handles, streams, host objects, etc. When an exception is thrown from this method, it typically means that the resource could not be explicitly freed.
+ If called more than once on the same object, the function should not throw an exception. However, this requirement is not enforced.
+ When using a Disposable object, in most circumstances it is good practice to create the instance with a `using` declaration, as the resource will be automatically disposed when the |Block| or |Module| immediately containing the declaration has been evaluated.
+ |
+
+
+
+
+
+
+ The AsyncDisposable Interface
+ The AsyncDisposable interface includes the property described in :
+
+
+
+ |
+ Property
+ |
+
+ Value
+ |
+
+ Requirements
+ |
+
+
+ |
+ `%Symbol.asyncDispose%`
+ |
+
+ a function object that returns a promise
+ |
+
+ Invoking this method notifies the AsyncDisposable object that the caller does not intend to continue to use this object. This method should perform any necessary logic to perform explicit clean-up of the resource including, but not limited to, file system handles, streams, host objects, etc. When the promise returned by this method is rejected, it typically means that the resource could not be explicitly freed. An AsyncDisposable object is not considered "disposed" until the resulting Promise has been fulfilled.
+ If called more than once on the same object, the function should not throw an exception or return a rejected promise. However, this requirement is not enforced.
+ When using an AsyncDisposable object, in most circumstances it is good practice to create the instance with a `await using` declaration, as the resource will be automatically disposed when the |Block| or |Module| immediately containing the declaration has been evaluated.
+ |
+
+
+
+
+
+
+
+
+ DisposableStack Objects
+ A DisposableStack is an object that can be used to contain one or more resources that should be disposed together.
+ Any DisposableStack object is in one of two mutually exclusive states: disposed or pending:
+
+ - A disposable stack `d` is pending if neither `d.dispose()` nor `d.move()` has been invoked for `d`.
+ - A disposable stack `d` is disposed if either `d.dispose()` or `d.move()` has been invoked for `d`.
+
+
+
+ The DisposableStack Constructor
+ The DisposableStack constructor:
+
+ - is %DisposableStack%.
+ - is the initial value of the *"DisposableStack"* property of the global object.
+ - creates and initializes a new DisposableStack when called as a constructor.
+ - is not intended to be called as a function and will throw an exception when called in that manner.
+ - may be used as the value in an `extends` clause of a class definition. Subclass constructors that intend to inherit the specified DisposableStack behaviour must include a `super` call to the DisposableStack constructor to create and initialize the subclass instance with the internal state necessary to support the `DisposableStack` and `DisposableStack.prototype` built-in methods.
+
+
+
+ DisposableStack ( )
+ This function performs the following steps when called:
+
+ 1. If NewTarget is *undefined*, throw a *TypeError* exception.
+ 1. Let _disposableStack_ be ? OrdinaryCreateFromConstructor(NewTarget, *"%DisposableStack.prototype%"*, « [[DisposableState]], [[DisposeCapability]] »).
+ 1. Set _disposableStack_.[[DisposableState]] to ~pending~.
+ 1. Set _disposableStack_.[[DisposeCapability]] to NewDisposeCapability().
+ 1. Return _disposableStack_.
+
+
+
+
+
+ Properties of the DisposableStack Constructor
+ The DisposableStack constructor:
+
+ - has a [[Prototype]] internal slot whose value is %Function.prototype%.
+ - has the following properties:
+
+
+
+ DisposableStack.prototype
+ The initial value of `DisposableStack.prototype` is the DisposableStack prototype object.
+ This property has the attributes { [[Writable]]: *false*, [[Enumerable]]: *false*, [[Configurable]]: *false* }.
+
+
+
+
+ Properties of the DisposableStack Prototype Object
+ The DisposableStack prototype object:
+
+ - is %DisposableStack.prototype%.
+ - has a [[Prototype]] internal slot whose value is %Object.prototype%.
+ - is an ordinary object.
+ - does not have a [[DisposableState]] internal slot or any of the other internal slots of DisposableStack instances.
+
+
+
+ DisposableStack.prototype.adopt ( _value_, _onDispose_ )
+ This method performs the following steps when called:
+
+ 1. Let _disposableStack_ be the *this* value.
+ 1. Perform ? RequireInternalSlot(_disposableStack_, [[DisposableState]]).
+ 1. If _disposableStack_.[[DisposableState]] is ~disposed~, throw a *ReferenceError* exception.
+ 1. If IsCallable(_onDispose_) is *false*, throw a *TypeError* exception.
+ 1. Let _closure_ be a new Abstract Closure with no parameters that captures _value_ and _onDispose_ and performs the following steps when called:
+ 1. Return ? Call(_onDispose_, *undefined*, « _value_ »).
+ 1. Let _F_ be CreateBuiltinFunction(_closure_, 0, *""*, « »).
+ 1. Perform ? AddDisposableResource(_disposableStack_.[[DisposeCapability]], *undefined*, ~sync-dispose~, _F_).
+ 1. Return _value_.
+
+
+
+
+ DisposableStack.prototype.constructor
+ The initial value of `DisposableStack.prototype.constructor` is %DisposableStack%.
+
+
+
+ DisposableStack.prototype.defer ( _onDispose_ )
+ This method performs the following steps when called:
+
+ 1. Let _disposableStack_ be the *this* value.
+ 1. Perform ? RequireInternalSlot(_disposableStack_, [[DisposableState]]).
+ 1. If _disposableStack_.[[DisposableState]] is ~disposed~, throw a *ReferenceError* exception.
+ 1. If IsCallable(_onDispose_) is *false*, throw a *TypeError* exception.
+ 1. Perform ? AddDisposableResource(_disposableStack_.[[DisposeCapability]], *undefined*, ~sync-dispose~, _onDispose_).
+ 1. Return *undefined*.
+
+
+
+
+ DisposableStack.prototype.dispose ( )
+ This method performs the following steps when called:
+
+ 1. Let _disposableStack_ be the *this* value.
+ 1. Perform ? RequireInternalSlot(_disposableStack_, [[DisposableState]]).
+ 1. If _disposableStack_.[[DisposableState]] is ~disposed~, return *undefined*.
+ 1. Set _disposableStack_.[[DisposableState]] to ~disposed~.
+ 1. Return ? DisposeResources(_disposableStack_.[[DisposeCapability]], NormalCompletion(*undefined*)).
+
+
+
+
+ get DisposableStack.prototype.disposed
+ `DisposableStack.prototype.disposed` is an accessor property whose set accessor function is *undefined*. Its get accessor function performs the following steps when called:
+
+ 1. Let _disposableStack_ be the *this* value.
+ 1. Perform ? RequireInternalSlot(_disposableStack_, [[DisposableState]]).
+ 1. If _disposableStack_.[[DisposableState]] is ~disposed~, return *true*.
+ 1. Return *false*.
+
+
+
+
+ DisposableStack.prototype.move ( )
+ This method performs the following steps when called:
+
+ 1. Let _disposableStack_ be the *this* value.
+ 1. Perform ? RequireInternalSlot(_disposableStack_, [[DisposableState]]).
+ 1. If _disposableStack_.[[DisposableState]] is ~disposed~, throw a *ReferenceError* exception.
+ 1. Let _newDisposableStack_ be ? OrdinaryCreateFromConstructor(%DisposableStack%, *"%DisposableStack.prototype%"*, « [[DisposableState]], [[DisposeCapability]] »).
+ 1. Set _newDisposableStack_.[[DisposableState]] to ~pending~.
+ 1. Set _newDisposableStack_.[[DisposeCapability]] to _disposableStack_.[[DisposeCapability]].
+ 1. Set _disposableStack_.[[DisposeCapability]] to NewDisposeCapability().
+ 1. Set _disposableStack_.[[DisposableState]] to ~disposed~.
+ 1. Return _newDisposableStack_.
+
+
+
+
+ DisposableStack.prototype.use ( _value_ )
+ This method performs the following steps when called:
+
+ 1. Let _disposableStack_ be the *this* value.
+ 1. Perform ? RequireInternalSlot(_disposableStack_, [[DisposableState]]).
+ 1. If _disposableStack_.[[DisposableState]] is ~disposed~, throw a *ReferenceError* exception.
+ 1. Perform ? AddDisposableResource(_disposableStack_.[[DisposeCapability]], _value_, ~sync-dispose~).
+ 1. Return _value_.
+
+
+
+
+ DisposableStack.prototype [ %Symbol.dispose% ] ( )
+ The initial value of the `%Symbol.dispose%` property is %DisposableStack.prototype.dispose%, defined in .
+
+
+
+ DisposableStack.prototype [ %Symbol.toStringTag% ]
+ The initial value of the `%Symbol.toStringTag%` property is the String value *"DisposableStack"*.
+ This property has the attributes { [[Writable]]: *false*, [[Enumerable]]: *false*, [[Configurable]]: *true* }.
+
+
+
+
+ Properties of DisposableStack Instances
+ DisposableStack instances are ordinary objects that inherit properties from the DisposableStack prototype object (the intrinsic %DisposableStack.prototype%). DisposableStack instances are initially created with internal slots described in .
+
+
+
+ |
+ Internal Slot
+ |
+
+ Type
+ |
+
+ Description
+ |
+
+
+ |
+ [[DisposableState]]
+ |
+
+ ~pending~ or ~disposed~
+ |
+
+ Governs how a disposable stack will react to incoming calls to its `%Symbol.dispose%` method.
+ |
+
+
+ |
+ [[DisposeCapability]]
+ |
+
+ a DisposeCapability Record
+ |
+
+ Resources to be disposed when the disposable stack is disposed.
+ |
+
+
+
+
+
+
+
+ AsyncDisposableStack Objects
+ An AsyncDisposableStack is an object that can be used to contain one or more resources that should be asynchronously disposed together.
+ Any AsyncDisposableStack object is in one of two mutually exclusive states: disposed or pending:
+
+ - An async-disposable stack `d` is pending if neither `d.disposeAsync()` nor `d.move()` has been invoked for `d`.
+ - An async-disposable stack `d` is disposed if either `d.disposeAsync()` or `d.move()` has been invoked for `d`.
+
+
+
+ The AsyncDisposableStack Constructor
+ The AsyncDisposableStack constructor:
+
+ - is %AsyncDisposableStack%.
+ - is the initial value of the *"AsyncDisposableStack"* property of the global object.
+ - creates and initializes a new AsyncDisposableStack when called as a constructor.
+ - is not intended to be called as a function and will throw an exception when called in that manner.
+ - may be used as the value in an `extends` clause of a class definition. Subclass constructors that intend to inherit the specified AsyncDisposableStack behaviour must include a `super` call to the AsyncDisposableStack constructor to create and initialize the subclass instance with the internal state necessary to support the `AsyncDisposableStack` and `AsyncDisposableStack.prototype` built-in methods.
+
+
+
+ AsyncDisposableStack ( )
+ This function performs the following steps when called:
+
+ 1. If NewTarget is *undefined*, throw a *TypeError* exception.
+ 1. Let _asyncDisposableStack_ be ? OrdinaryCreateFromConstructor(NewTarget, *"%AsyncDisposableStack.prototype%"*, « [[AsyncDisposableState]], [[DisposeCapability]] »).
+ 1. Set _asyncDisposableStack_.[[AsyncDisposableState]] to ~pending~.
+ 1. Set _asyncDisposableStack_.[[DisposeCapability]] to NewDisposeCapability().
+ 1. Return _asyncDisposableStack_.
+
+
+
+
+
+ Properties of the AsyncDisposableStack Constructor
+ The AsyncDisposableStack constructor:
+
+ - has a [[Prototype]] internal slot whose value is %Function.prototype%.
+ - has the following properties:
+
+
+
+ AsyncDisposableStack.prototype
+ The initial value of `AsyncDisposableStack.prototype` is the AsyncDisposableStack prototype object.
+ This property has the attributes { [[Writable]]: *false*, [[Enumerable]]: *false*, [[Configurable]]: *false* }.
+
+
+
+
+ Properties of the AsyncDisposableStack Prototype Object
+ The AsyncDisposableStack prototype object:
+
+ - is %AsyncDisposableStack.prototype%.
+ - has a [[Prototype]] internal slot whose value is %Object.prototype%.
+ - is an ordinary object.
+ - does not have an [[AsyncDisposableState]] internal slot or any of the other internal slots of AsyncDisposableStack instances.
+
+
+
+ AsyncDisposableStack.prototype.adopt ( _value_, _onDisposeAsync_ )
+ This method performs the following steps when called:
+
+ 1. Let _asyncDisposableStack_ be the *this* value.
+ 1. Perform ? RequireInternalSlot(_asyncDisposableStack_, [[AsyncDisposableState]]).
+ 1. If _asyncDisposableStack_.[[AsyncDisposableState]] is ~disposed~, throw a *ReferenceError* exception.
+ 1. If IsCallable(_onDisposeAsync_) is *false*, throw a *TypeError* exception.
+ 1. Let _closure_ be a new Abstract Closure with no parameters that captures _value_ and _onDisposeAsync_ and performs the following steps when called:
+ 1. Return ? Call(_onDisposeAsync_, *undefined*, « _value_ »).
+ 1. Let _F_ be CreateBuiltinFunction(_closure_, 0, *""*, « »).
+ 1. Perform ? AddDisposableResource(_asyncDisposableStack_.[[DisposeCapability]], *undefined*, ~async-dispose~, _F_).
+ 1. Return _value_.
+
+
+
+
+ AsyncDisposableStack.prototype.constructor
+ The initial value of `AsyncDisposableStack.prototype.constructor` is %AsyncDisposableStack%.
+
+
+
+ AsyncDisposableStack.prototype.defer ( _onDisposeAsync_ )
+ This method performs the following steps when called:
+
+ 1. Let _asyncDisposableStack_ be the *this* value.
+ 1. Perform ? RequireInternalSlot(_asyncDisposableStack_, [[AsyncDisposableState]]).
+ 1. If _asyncDisposableStack_.[[AsyncDisposableState]] is ~disposed~, throw a *ReferenceError* exception.
+ 1. If IsCallable(_onDisposeAsync_) is *false*, throw a *TypeError* exception.
+ 1. Perform ? AddDisposableResource(_asyncDisposableStack_.[[DisposeCapability]], *undefined*, ~async-dispose~, _onDisposeAsync_).
+ 1. Return *undefined*.
+
+
+
+
+ AsyncDisposableStack.prototype.disposeAsync ( )
+ This async method performs the following steps when called:
+
+ 1. Let _asyncDisposableStack_ be the *this* value.
+ 1. Perform ? RequireInternalSlot(_asyncDisposableStack_, [[AsyncDisposableState]]).
+ 1. If _asyncDisposableStack_.[[AsyncDisposableState]] is ~disposed~, return *undefined*.
+ 1. Set _asyncDisposableStack_.[[AsyncDisposableState]] to ~disposed~.
+ 1. Return ? DisposeResources(_asyncDisposableStack_.[[DisposeCapability]], NormalCompletion(*undefined*)).
+
+
+
+
+ get AsyncDisposableStack.prototype.disposed
+ `AsyncDisposableStack.prototype.disposed` is an accessor property whose set accessor function is *undefined*. Its get accessor function performs the following steps when called:
+
+ 1. Let _asyncDisposableStack_ be the *this* value.
+ 1. Perform ? RequireInternalSlot(_asyncDisposableStack_, [[AsyncDisposableState]]).
+ 1. If _asyncDisposableStack_.[[AsyncDisposableState]] is ~disposed~, return *true*.
+ 1. Return *false*.
+
+
+
+
+ AsyncDisposableStack.prototype.move ( )
+ This method performs the following steps when called:
+
+ 1. Let _asyncDisposableStack_ be the *this* value.
+ 1. Perform ? RequireInternalSlot(_asyncDisposableStack_, [[AsyncDisposableState]]).
+ 1. If _asyncDisposableStack_.[[AsyncDisposableState]] is ~disposed~, throw a *ReferenceError* exception.
+ 1. Let _newAsyncDisposableStack_ be ? OrdinaryCreateFromConstructor(%AsyncDisposableStack%, *"%AsyncDisposableStack.prototype%"*, « [[AsyncDisposableState]], [[DisposeCapability]] »).
+ 1. Set _newAsyncDisposableStack_.[[AsyncDisposableState]] to ~pending~.
+ 1. Set _newAsyncDisposableStack_.[[DisposeCapability]] to _asyncDisposableStack_.[[DisposeCapability]].
+ 1. Set _asyncDisposableStack_.[[DisposeCapability]] to NewDisposeCapability().
+ 1. Set _asyncDisposableStack_.[[AsyncDisposableState]] to ~disposed~.
+ 1. Return _newAsyncDisposableStack_.
+
+
+
+
+ AsyncDisposableStack.prototype.use ( _value_ )
+ This method performs the following steps when called:
+
+ 1. Let _asyncDisposableStack_ be the *this* value.
+ 1. Perform ? RequireInternalSlot(_asyncDisposableStack_, [[AsyncDisposableState]]).
+ 1. If _asyncDisposableStack_.[[AsyncDisposableState]] is ~disposed~, throw a *ReferenceError* exception.
+ 1. Perform ? AddDisposableResource(_asyncDisposableStack_.[[DisposeCapability]], _value_, ~async-dispose~).
+ 1. Return _value_.
+
+
+
+
+ AsyncDisposableStack.prototype [ %Symbol.asyncDispose% ] ( )
+ The initial value of the `%Symbol.asyncDispose%` property is %AsyncDisposableStack.prototype.disposeAsync%, defined in .
+
+
+
+ AsyncDisposableStack.prototype [ %Symbol.toStringTag% ]
+ The initial value of the `%Symbol.toStringTag%` property is the String value *"AsyncDisposableStack"*.
+ This property has the attributes { [[Writable]]: *false*, [[Enumerable]]: *false*, [[Configurable]]: *true* }.
+
+
+
+
+ Properties of AsyncDisposableStack Instances
+ AsyncDisposableStack instances are ordinary objects that inherit properties from the AsyncDisposableStack prototype object (the intrinsic %AsyncDisposableStack.prototype%). AsyncDisposableStack instances are initially created with internal slots described in .
+
+
+
+ |
+ Internal Slot
+ |
+
+ Type
+ |
+
+ Description
+ |
+
+
+ |
+ [[AsyncDisposableState]]
+ |
+
+ ~pending~ or ~disposed~
+ |
+
+ Governs how a disposable stack will react to incoming calls to its `%Symbol.asyncDispose%` method.
+ |
+
+
+ |
+ [[DisposeCapability]]
+ |
+
+ a DisposeCapability Record
+ |
+
+ Resources to be disposed when the disposable stack is disposed.
+ |
+
+
+
+
+
+
Promise Objects
A Promise is an object that is used as a placeholder for the eventual results of a deferred (and possibly asynchronous) computation.
@@ -52410,6 +53649,14 @@ Expressions
+
+
+ When processing an instance of the production
+
+ the interpretation of |CoverAwaitExpressionAndAwaitUsingDeclarationHead| is refined using the following grammar:
+
+
+
@@ -52460,8 +53707,17 @@ Statements
+
+
+
+ When processing an instance of the production
+
+ the interpretation of |CoverAwaitExpressionAndAwaitUsingDeclarationHead| is refined using the following grammar:
+
+
+
|