From ec8df9367061568c4d02415572d02c7b5ef616e4 Mon Sep 17 00:00:00 2001 From: Mahoo Huang <45908451+Mahoo12138@users.noreply.github.com> Date: Fri, 23 Jun 2023 07:19:05 +0800 Subject: [PATCH 01/11] Typo in README.md (#162) --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 1ed96e4..2727f0d 100644 --- a/README.md +++ b/README.md @@ -295,7 +295,7 @@ This proposal is motivated by a number of cases: # Definitions - _Resource_ — An object with a specific lifetime, at the end of which either a lifetime-sensitive operation - should be performed or a non-gargbage-collected reference (such as a file handle, socket, etc.) should be closed or + should be performed or a non-garbage-collected reference (such as a file handle, socket, etc.) should be closed or freed. - _Resource Management_ — A process whereby "resources" are released, triggering any lifetime-sensitive operations or freeing any related non-garbage-collected references. @@ -896,7 +896,7 @@ async function f() { It is important that such an implicit interleaving point be adequately indicated within the syntax. We believe that the presence of `await using` within such a block is an adequate indicator, since it should be fairly easy to recognize -a _Block_ containing an `await using` statement in well-formated code. +a _Block_ containing an `await using` statement in well-formatted code. It is also feasible for editors to use features such as syntax highlighting, editor decorations, and inlay hints to further highlight such transitions, without needing to specify additional syntax. From 3b576c0bb756fcbb4b91c5556c3609806f9abaf9 Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Tue, 27 Jun 2023 16:22:36 -0400 Subject: [PATCH 02/11] Fix missing text from async spec (#163) * Fix missing text from async spec * Add NOTE to algorithm steps --- spec.emu | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/spec.emu b/spec.emu index a407eea..7c8fdb6 100644 --- a/spec.emu +++ b/spec.emu @@ -1019,8 +1019,9 @@ contributors: Ron Buckton, Ecma International 1. If _method_ is not present then, - 1. If _V_ is *null* or *undefined*, return ~unused~. - 1. If Type(_V_) is not Object, throw a *TypeError* exception. + 1. If _V_ is either *null* or *undefined* and _hint_ is ~sync-dispose~, then + 1. Return ~unused~. + 1. NOTE: When _V_ is either *null* or *undefined* and _hint_ 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(_V_, _hint_). 1. Else, 1. Assert: _V_ is *undefined*. @@ -1041,9 +1042,13 @@ contributors: Ron Buckton, Ecma International
1. If _method_ is not present, then - 1. If _V_ is *undefined*, throw a *TypeError* exception. - 1. Set _method_ to ? GetDisposeMethod(_V_, _hint_). - 1. If _method_ is *undefined*, throw a *TypeError* exception. + 1. If _V_ is either *null* or *undefined*, then + 1. Set _V_ to *undefined*. + 1. Set _method_ to *undefined*. + 1. Else, + 1. If _V_ is not an Object, throw a *TypeError* exception. + 1. Set _method_ to ? GetDisposeMethod(_V_, _hint_). + 1. If _method_ is *undefined*, throw a *TypeError* exception. 1. Else, 1. If IsCallable(_method_) is *false*, throw a *TypeError* exception. 1. Return the DisposableResource Record { [[ResourceValue]]: _V_, [[Hint]]: _hint_, [[DisposeMethod]]: _method_ }. From 2af9787ffdab2ee034a7a1f8a0f51f18556ea9a2 Mon Sep 17 00:00:00 2001 From: Pedro Augusto de Paula Barbosa Date: Thu, 6 Jul 2023 20:39:24 -0300 Subject: [PATCH 03/11] Fix grammar description for `await using` declarations (#184) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2727f0d..5e6c5eb 100644 --- a/README.md +++ b/README.md @@ -666,7 +666,7 @@ This will not dispose resources that are not iterated, such as if iteration is t ```grammarkdown UsingDeclaration : - `using` `await` BindingList `;` + `await` `using` BindingList `;` LexicalBinding : BindingIdentifier Initializer From 40f272ff93bd1068e25ca46ce04559ec131f24fe Mon Sep 17 00:00:00 2001 From: Pedro Augusto de Paula Barbosa Date: Thu, 6 Jul 2023 20:40:19 -0300 Subject: [PATCH 04/11] Improve readme on nullish values in `await using` (#183) --- README.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 5e6c5eb..bbc0940 100644 --- a/README.md +++ b/README.md @@ -818,10 +818,9 @@ order. ### `await using` Declarations and `null` or `undefined` Values -This proposal has opted to ignore `null` and `undefined` values provided to `await using` declarations. This is similar -to the behavior of `using` in the original [Explicit Resource Management][using] proposal, which also -allows `null` and `undefined`, as well as C#, which also allows `null`,. One primary reason for this behavior is to -simplify a common case where a resource might be optional, without requiring duplication of work or needless +This proposal has opted to ignore `null` and `undefined` values provided to `await using` declarations. This is +consistent with the proposed behavior for the `using` declarations in this proposal. Like in the sync case, this allows +simplifying a common case where a resource might be optional, without requiring duplication of work or needless allocations: ```js From a3edfa6d305444a43c418a71db59614802679a61 Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Thu, 13 Jul 2023 08:54:29 -0400 Subject: [PATCH 05/11] Add missing .prototype property entries for DisposableStack/AsyncDisposableStack (#167) --- spec.emu | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/spec.emu b/spec.emu index 7c8fdb6..b24b975 100644 --- a/spec.emu +++ b/spec.emu @@ -4401,8 +4401,15 @@ contributors: Ron Buckton, Ecma International

Properties of the DisposableStack Constructor

The DisposableStack constructor:

    -
  • Has a [[Prototype]] internal slot whose value is %Function.prototype%.
  • +
  • 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* }.

+
@@ -4600,8 +4607,14 @@ contributors: Ron Buckton, Ecma International

Properties of the AsyncDisposableStack Constructor

The AsyncDisposableStack constructor:

    -
  • Has a [[Prototype]] internal slot whose value is %Function.prototype%.
  • +
  • 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* }.

+
From 8b709793a07d4ffec0a90baa92bfbf7e7208df6b Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Thu, 13 Jul 2023 12:23:23 -0400 Subject: [PATCH 06/11] Ignore return value of [Symbol.dispose]() method when hint is 'async-dispose' (#180) * Ignore return value of [Symbol.dispose]() method when hint is 'async-dispose' * Apply suggestions from PR --- spec.emu | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/spec.emu b/spec.emu index b24b975..9d766f5 100644 --- a/spec.emu +++ b/spec.emu @@ -1068,6 +1068,12 @@ contributors: Ron Buckton, Ecma International 1. Let _method_ be ? GetMethod(_V_, @@asyncDispose). 1. If _method_ is *undefined*, then 1. Set _method_ to ? GetMethod(_V_, @@dispose). + 1. Let _closure_ be a new Abstract Closure with no parameters that captures _method_ and performs the following steps when called: + 1. Let _O_ be the *this* value. + 1. Perform ? Call(_method_, _O_). + 1. Return *undefined*. + 1. NOTE: This function is not observable to user code. It is used to ensure that a Promise returned from a synchronous `@@dispose` method will not be awaited. + 1. Return CreateBuiltinFunction(_closure_, 0, *""*, « »). 1. Else, 1. Let _method_ be ? GetMethod(_V_, @@dispose). 1. Return _method_. From 06e6070442b7a2bd3bc18730dc78cb7ee9a88130 Mon Sep 17 00:00:00 2001 From: Casey Occhialini <1508707+littlespex@users.noreply.github.com> Date: Tue, 7 Nov 2023 15:22:40 -0800 Subject: [PATCH 07/11] typo fix (#200) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index bbc0940..7718d0d 100644 --- a/README.md +++ b/README.md @@ -1317,7 +1317,7 @@ new SuppressedError( ### Interoperation and Customization -The `DisposableStack` and `AsyncDisposableStack` classes also provid the ability to create a disposable resource from a +The `DisposableStack` and `AsyncDisposableStack` classes also provide the ability to create a disposable resource from a simple callback. This callback will be executed when the stack's disposal method is executed. The ability to create a disposable resource from a callback has several benefits: From e53b73f89e83014bcaa506d63367357f045f4ea9 Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Wed, 20 Mar 2024 15:24:03 -0400 Subject: [PATCH 08/11] Correctly use hint in ForIn/OfBodyEvaluation (#171) --- spec.emu | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/spec.emu b/spec.emu index 9d766f5..f2f5835 100644 --- a/spec.emu +++ b/spec.emu @@ -2996,10 +2996,7 @@ contributors: Ron Buckton, Ecma International 1. Let _lhsName_ be the sole element of BoundNames of _lhs_. 1. Let _lhsRef_ be ! ResolveBinding(_lhsName_). 1. Let _status_ be Completion(InitializeReferencedBinding(_lhsRef_, _nextValue_)). - 1. If IsUsingDeclaration of _lhs_ is *true*, then - 1. Let _status_ be Completion(InitializeReferencedBinding(_lhsRef_, _nextValue_, ~sync-dispose~)). - 1. Else, - 1. Let _status_ be Completion(InitializeReferencedBinding(_lhsRef_, _nextValue_, ~normal~)). + 1. Let _status_ be Completion(InitializeReferencedBinding(_lhsRef_, _nextValue_, _hint_)). 1. If _status_ is an abrupt completion, then 1. If _iterationEnv_ is not *undefined*, then 1. Set _status_ to Completion(DisposeResources(_iterationEnv_.[[DisposeCapability]], _status_)). From e1ef220fdb379394e384fe99742761cfcd6e8385 Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Wed, 20 Mar 2024 15:24:58 -0400 Subject: [PATCH 09/11] Add missing calls to NewDisposeCapability AOs (#175) --- spec.emu | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/spec.emu b/spec.emu index f2f5835..e105326 100644 --- a/spec.emu +++ b/spec.emu @@ -2315,6 +2315,44 @@ contributors: Ron Buckton, Ecma International 1. Return _env_.
+ + +

+ NewFunctionEnvironment ( + _F_: an ECMAScript function, + _newTarget_: an Object or *undefined*, + ): a Function Environment Record +

+
+
+ + 1. Let _env_ be a new Function Environment Record containing no bindings. + 1. Set _env_.[[FunctionObject]] to _F_. + 1. If _F_.[[ThisMode]] is ~lexical~, set _env_.[[ThisBindingStatus]] to ~lexical~. + 1. Else, set _env_.[[ThisBindingStatus]] to ~uninitialized~. + 1. Set _env_.[[NewTarget]] to _newTarget_. + 1. Set _env_.[[OuterEnv]] to _F_.[[Environment]]. + 1. Set _env_.[[DisposeCapability]] to NewDisposeCapability(). + 1. Return _env_. + +
+ + +

+ NewModuleEnvironment ( + _E_: an Environment Record, + ): a Module Environment Record +

+
+
+ + 1. Let _env_ be a new Module Environment Record containing no bindings. + 1. Set _env_.[[OuterEnv]] to _E_. + 1. Set _env_.[[DisposeCapability]] to NewDisposeCapability(). + 1. Return _env_. + +
+ From 263aa4c45e82fffe007a6ca05557f5426c97da45 Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Wed, 20 Mar 2024 15:34:19 -0400 Subject: [PATCH 10/11] Move DisposeResources to Evaluation of FunctionStatementList (#178) --- spec.emu | 188 +++++++++++-------------------------------------------- 1 file changed, 37 insertions(+), 151 deletions(-) diff --git a/spec.emu b/spec.emu index e105326..5fd1008 100644 --- a/spec.emu +++ b/spec.emu @@ -3097,25 +3097,6 @@ contributors: Ron Buckton, Ecma International

Function Definitions

- -

- Runtime Semantics: EvaluateFunctionBody ( - _functionObject_: unknown, - _argumentsList_: a List, - ): either a normal completion containing an ECMAScript language value or an abrupt completion -

-
-
- FunctionBody : FunctionStatementList - - 1. Perform ? FunctionDeclarationInstantiation(_functionObject_, _argumentsList_). - 1. Return ? Evaluation of |FunctionStatementList|. - 1. Let _result_ be Completion(Evaluation of |FunctionStatementList|). - 1. Let _env_ be the running execution context's LexicalEnvironment. - 1. Return ? DisposeResources(_env_.[[DisposeCapability]], _result_). - -
-

Runtime Semantics: InstantiateOrdinaryFunctionExpression ( @@ -3154,6 +3135,43 @@ contributors: Ron Buckton, Ecma International

The |BindingIdentifier| in a |FunctionExpression| can be referenced from inside the |FunctionExpression|'s |FunctionBody| to allow the function to call itself recursively. However, unlike in a |FunctionDeclaration|, the |BindingIdentifier| in a |FunctionExpression| cannot be referenced from and does not affect the scope enclosing the |FunctionExpression|.

+ + +

Runtime Semantics: Evaluation

+ FunctionDeclaration : `function` BindingIdentifier `(` FormalParameters `)` `{` FunctionBody `}` + + 1. Return ~empty~. + + +

An alternative semantics is provided in .

+
+ FunctionDeclaration : `function` `(` FormalParameters `)` `{` FunctionBody `}` + + 1. Return ~empty~. + + + FunctionExpression : `function` BindingIdentifier? `(` FormalParameters `)` `{` FunctionBody `}` + + + 1. Return InstantiateOrdinaryFunctionExpression of |FunctionExpression|. + + +

A *"prototype"* property is automatically created for every function defined using a |FunctionDeclaration| or |FunctionExpression|, to allow for the possibility that the function will be used as a constructor.

+
+ FunctionStatementList : [empty] + + 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_). + + +
@@ -4813,138 +4831,6 @@ contributors: Ron Buckton, Ecma International - - -

Generator Objects

- - -

Generator Abstract Operations

- - -

- GeneratorStart ( - _generator_: unknown, - _generatorBody_: a |FunctionBody| Parse Node or an Abstract Closure with no parameters, - ): ~unused~ -

-
-
- - 1. Assert: The value of _generator_.[[GeneratorState]] is *undefined*. - 1. Let _genContext_ be the running execution context. - 1. Set the Generator component of _genContext_ to _generator_. - 1. [fence-effects="user-code"] Set the code evaluation state of _genContext_ such that when evaluation is resumed for that execution context the following steps will be performed: - 1. If _generatorBody_ is a Parse Node, then - 1. Let _result_ be the result of evaluating _generatorBody_. - 1. Else, - 1. Assert: _generatorBody_ is an Abstract Closure with no parameters. - 1. Let _result_ be _generatorBody_(). - 1. Assert: If we return here, the generator either threw an exception or performed either an implicit or explicit return. - 1. Remove _genContext_ from the execution context stack and restore the execution context that is at the top of the execution context stack as the running execution context. - 1. Set _generator_.[[GeneratorState]] to ~completed~. - 1. Once a generator enters the ~completed~ state it never leaves it and its associated execution context is never resumed. Any execution state associated with _generator_ can be discarded at this point. - 1. Let _env_ be _genContext_'s LexicalEnvironment. - 1. Set _result_ to DisposeResources(_env_.[[DisposeCapability]], _result_). - 1. If _result_.[[Type]] is ~normal~, let _resultValue_ be *undefined*. - 1. Else if _result_.[[Type]] is ~return~, let _resultValue_ be _result_.[[Value]]. - 1. Else, - 1. Assert: _result_.[[Type]] is ~throw~. - 1. Return ? _result_. - 1. Return CreateIterResultObject(_resultValue_, *true*). - 1. Set _generator_.[[GeneratorContext]] to _genContext_. - 1. Set _generator_.[[GeneratorState]] to ~suspendedStart~. - 1. Return ~unused~. - -
-
-
- - -

AsyncGenerator Objects

- - -

AsyncGenerator Abstract Operations

- - -

- AsyncGeneratorStart ( - _generator_: an AsyncGenerator, - _generatorBody_: a |FunctionBody| Parse Node or an Abstract Closure with no parameters, - ): ~unused~ -

-
-
- - 1. Assert: _generator_.[[AsyncGeneratorState]] is *undefined*. - 1. Let _genContext_ be the running execution context. - 1. Set the Generator component of _genContext_ to _generator_. - 1. [fence-effects="user-code"] Set the code evaluation state of _genContext_ such that when evaluation is resumed for that execution context the following steps will be performed: - 1. If _generatorBody_ is a Parse Node, then - 1. Let _result_ be the result of evaluating _generatorBody_. - 1. Else, - 1. Assert: _generatorBody_ is an Abstract Closure with no parameters. - 1. Let _result_ be Completion(_generatorBody_()). - 1. Assert: If we return here, the async generator either threw an exception or performed either an implicit or explicit return. - 1. Remove _genContext_ from the execution context stack and restore the execution context that is at the top of the execution context stack as the running execution context. - 1. Set _generator_.[[AsyncGeneratorState]] to ~completed~. - 1. Let _env_ be _genContext_'s LexicalEnvironment. - 1. Set _result_ to DisposeResources(_env_.[[DisposeCapability]], _result_). - 1. If _result_.[[Type]] is ~normal~, set _result_ to NormalCompletion(*undefined*). - 1. If _result_.[[Type]] is ~return~, set _result_ to NormalCompletion(_result_.[[Value]]). - 1. Perform AsyncGeneratorCompleteStep(_generator_, _result_, *true*). - 1. Perform AsyncGeneratorDrainQueue(_generator_). - 1. Return *undefined*. - 1. Set _generator_.[[AsyncGeneratorContext]] to _genContext_. - 1. Set _generator_.[[AsyncGeneratorState]] to ~suspendedStart~. - 1. Set _generator_.[[AsyncGeneratorQueue]] to a new empty List. - 1. Return ~unused~. - -
-
-
- - -

AsyncFunction Objects

- - -

Async Functions Abstract Operations

- - -

- AsyncBlockStart ( - _promiseCapability_: a PromiseCapability Record, - _asyncBody_: a Parse Node, - _asyncContext_: an execution context, - ): ~unused~ -

-
-
- - 1. Assert: _promiseCapability_ is a PromiseCapability Record. - 1. Let _runningContext_ be the running execution context. - 1. [fence-effects="user-code"] Set the code evaluation state of _asyncContext_ such that when evaluation is resumed for that execution context the following steps will be performed: - 1. Let _result_ be the result of evaluating _asyncBody_. - 1. Assert: If we return here, the async function either threw an exception or performed an implicit or explicit return; all awaiting is done. - 1. Remove _asyncContext_ from the execution context stack and restore the execution context that is at the top of the execution context stack as the running execution context. - 1. Let _env_ be _asyncContext_'s LexicalEnvironment. - 1. Set _result_ to DisposeResources(_env_.[[DisposeCapability]], _result_). - 1. If _result_.[[Type]] is ~normal~, then - 1. Perform ! Call(_promiseCapability_.[[Resolve]], *undefined*, « *undefined* »). - 1. Else if _result_.[[Type]] is ~return~, then - 1. Perform ! Call(_promiseCapability_.[[Resolve]], *undefined*, « _result_.[[Value]] »). - 1. Else, - 1. Assert: _result_.[[Type]] is ~throw~. - 1. Perform ! Call(_promiseCapability_.[[Reject]], *undefined*, « _result_.[[Value]] »). - 1. [id="step-asyncblockstart-return-undefined"] Return ~unused~. - 1. Push _asyncContext_ onto the execution context stack; _asyncContext_ is now the running execution context. - 1. Resume the suspended evaluation of _asyncContext_. Let _result_ be the value returned by the resumed computation. - 1. Assert: When we return here, _asyncContext_ has already been removed from the execution context stack and _runningContext_ is the currently running execution context. - 1. Assert: _result_ is a normal completion with a value of ~unused~. The possible sources of this value are Await or, if the async function doesn't await anything, step above. - 1. Return ~unused~. - -
-
-
From d8db6733f9fc0284dfc2b7f053b56e18bcdf45e3 Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Fri, 22 Mar 2024 12:26:04 -0400 Subject: [PATCH 11/11] Update to latest version of ECMA-262 (#166) --- spec.emu | 441 +++++++++++++++++++++++++++++-------------------------- 1 file changed, 230 insertions(+), 211 deletions(-) diff --git a/spec.emu b/spec.emu index 5fd1008..6876dae 100644 --- a/spec.emu +++ b/spec.emu @@ -875,17 +875,14 @@ contributors: Ron Buckton, Ecma International

InitializeReferencedBinding ( - _V_: unknown, - _W_: unknown, + _V_: a Reference Record, + _W_: a Reference Record, _hint_: one of ~normal~, ~sync-dispose~, or ~async-dispose~, ): either a normal completion containing ~unused~ or an abrupt completion

- 1. ReturnIfAbrupt(_V_). - 1. ReturnIfAbrupt(_W_). - 1. Assert: _V_ is a Reference Record. 1. Assert: IsUnresolvableReference(_V_) is *false*. 1. Let _base_ be _V_.[[Base]]. 1. Assert: _base_ is an Environment Record. @@ -975,7 +972,7 @@ contributors: Ron Buckton, Ecma International ~sync-dispose~ or ~async-dispose~. - Indicates whether the resource was added by a `using` declaration or DisposableStack object (~sync-dispose~) or a `await using` declaration or AsyncDisposableStack object (~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~). @@ -1114,8 +1111,8 @@ contributors: Ron Buckton, Ecma International 1. Set _result_ to _result_.[[Value]]. 1. Let _suppressed_ be _completion_.[[Value]]. 1. Let _error_ be a newly created *SuppressedError* object. - 1. Perform ! CreateNonEnumerableDataPropertyOrThrow(_error_, *"error"*, _result_). - 1. Perform ! CreateNonEnumerableDataPropertyOrThrow(_error_, *"suppressed"*, _suppressed_). + 1. Perform CreateNonEnumerableDataPropertyOrThrow(_error_, *"error"*, _result_). + 1. Perform CreateNonEnumerableDataPropertyOrThrow(_error_, *"suppressed"*, _suppressed_). 1. Set _completion_ to ThrowCompletion(_error_). 1. Else, 1. Set _completion_ to _result_. @@ -1144,11 +1141,11 @@ contributors: Ron Buckton, Ecma International BindingIdentifier : `yield` - 1. Return « *"yield"* ». + 1. Return « *"yield"* ». BindingIdentifier : `await` - 1. Return « *"await"* ». + 1. Return « *"await"* ». LexicalDeclaration : LetOrConst BindingList `;` @@ -1260,7 +1257,7 @@ contributors: Ron Buckton, Ecma International FunctionDeclaration : `function` `(` FormalParameters `)` `{` FunctionBody `}` - 1. Return « *"\*default\*"* ». + 1. Return « *"\*default\*"* ». FormalParameters : [empty] @@ -1289,7 +1286,7 @@ contributors: Ron Buckton, Ecma International GeneratorDeclaration : `function` `*` `(` FormalParameters `)` `{` GeneratorBody `}` - 1. Return « *"\*default\*"* ». + 1. Return « *"\*default\*"* ». AsyncGeneratorDeclaration : `async` `function` `*` BindingIdentifier `(` FormalParameters `)` `{` AsyncGeneratorBody `}` @@ -1297,7 +1294,7 @@ contributors: Ron Buckton, Ecma International AsyncGeneratorDeclaration : `async` `function` `*` `(` FormalParameters `)` `{` AsyncGeneratorBody `}` - 1. Return « *"\*default\*"* ». + 1. Return « *"\*default\*"* ». ClassDeclaration : `class` BindingIdentifier ClassTail @@ -1305,7 +1302,7 @@ contributors: Ron Buckton, Ecma International ClassDeclaration : `class` ClassTail - 1. Return « *"\*default\*"* ». + 1. Return « *"\*default\*"* ». AsyncFunctionDeclaration : `async` `function` BindingIdentifier `(` FormalParameters `)` `{` AsyncFunctionBody `}` @@ -1317,7 +1314,7 @@ contributors: Ron Buckton, Ecma International AsyncFunctionDeclaration : `async` `function` `(` FormalParameters `)` `{` AsyncFunctionBody `}` - 1. Return « *"\*default\*"* ». + 1. Return « *"\*default\*"* ». CoverCallExpressionAndAsyncArrowHead : MemberExpression Arguments @@ -1390,7 +1387,7 @@ contributors: Ron Buckton, Ecma International ExportDeclaration : `export` `default` AssignmentExpression `;` - 1. Return « *"\*default\*"* ». + 1. Return « *"\*default\*"* ».
@@ -1759,8 +1756,8 @@ contributors: Ron Buckton, Ecma International

Runtime Semantics: IteratorBindingInitialization ( - _iteratorRecord_: unknown, - _environment_: unknown, + _iteratorRecord_: an Iterator Record, + _environment_: an Environment Record or *undefined*, ): either a normal completion containing ~unused~ or an abrupt completion

@@ -1813,7 +1810,8 @@ contributors: Ron Buckton, Ecma International 1. Let _next_ be Completion(IteratorStep(_iteratorRecord_)). 1. If _next_ is an abrupt completion, set _iteratorRecord_.[[Done]] to *true*. 1. ReturnIfAbrupt(_next_). - 1. If _next_ is *false*, set _iteratorRecord_.[[Done]] to *true*. + 1. If _next_ is *false*, then + 1. Set _iteratorRecord_.[[Done]] to *true*. 1. Else, 1. Set _v_ to Completion(IteratorValue(_next_)). 1. If _v_ is an abrupt completion, set _iteratorRecord_.[[Done]] to *true*. @@ -1822,7 +1820,7 @@ contributors: Ron Buckton, Ecma International 1. If IsAnonymousFunctionDefinition(|Initializer|) is *true*, then 1. Set _v_ to ? NamedEvaluation of |Initializer| with argument _bindingId_. 1. Else, - 1. Let _defaultValue_ be the result of evaluating |Initializer|. + 1. Let _defaultValue_ be ? Evaluation of |Initializer|. 1. Set _v_ to ? GetValue(_defaultValue_). 1. If _environment_ is *undefined*, return ? PutValue(_lhs_, _v_). 1. Return ? InitializeReferencedBinding(_lhs_, _v_, ~normal~). @@ -1834,13 +1832,14 @@ contributors: Ron Buckton, Ecma International 1. Let _next_ be Completion(IteratorStep(_iteratorRecord_)). 1. If _next_ is an abrupt completion, set _iteratorRecord_.[[Done]] to *true*. 1. ReturnIfAbrupt(_next_). - 1. If _next_ is *false*, set _iteratorRecord_.[[Done]] to *true*. + 1. If _next_ is *false*, then + 1. Set _iteratorRecord_.[[Done]] to *true*. 1. Else, 1. Set _v_ to Completion(IteratorValue(_next_)). 1. If _v_ is an abrupt completion, set _iteratorRecord_.[[Done]] to *true*. 1. ReturnIfAbrupt(_v_). 1. If |Initializer| is present and _v_ is *undefined*, then - 1. Let _defaultValue_ be the result of evaluating |Initializer|. + 1. Let _defaultValue_ be ? Evaluation of |Initializer|. 1. Set _v_ to ? GetValue(_defaultValue_). 1. Return ? BindingInitialization of |BindingPattern| with arguments _v_ and _environment_. @@ -1903,7 +1902,8 @@ contributors: Ron Buckton, Ecma International 1. Let _next_ be Completion(IteratorStep(_iteratorRecord_)). 1. If _next_ is an abrupt completion, set _iteratorRecord_.[[Done]] to *true*. 1. ReturnIfAbrupt(_next_). - 1. If _next_ is *false*, set _iteratorRecord_.[[Done]] to *true*. + 1. If _next_ is *false*, then + 1. Set _iteratorRecord_.[[Done]] to *true*. 1. Else, 1. Set _v_ to Completion(IteratorValue(_next_)). 1. If _v_ is an abrupt completion, set _iteratorRecord_.[[Done]] to *true*. @@ -1924,7 +1924,8 @@ contributors: Ron Buckton, Ecma International 1. Let _next_ be Completion(IteratorStep(_iteratorRecord_)). 1. If _next_ is an abrupt completion, set _iteratorRecord_.[[Done]] to *true*. 1. ReturnIfAbrupt(_next_). - 1. If _next_ is *false*, set _iteratorRecord_.[[Done]] to *true*. + 1. If _next_ is *false*, then + 1. Set _iteratorRecord_.[[Done]] to *true*. 1. Else, 1. Set _v_ to Completion(IteratorValue(_next_)). 1. If _v_ is an abrupt completion, set _iteratorRecord_.[[Done]] to *true*. @@ -2103,7 +2104,7 @@ contributors: Ron Buckton, Ecma International

Executable Code and Execution Contexts

Environment Records

-

Environment Record is a specification type used to define the association of |Identifier|s to specific variables and functions, based upon the lexical nesting structure of ECMAScript code. Usually an Environment Record is associated with some specific syntactic structure of ECMAScript code such as a |FunctionDeclaration|, a |BlockStatement|, or a |Catch| clause of a |TryStatement|. Each time such code is evaluated, a new Environment Record is created to record the identifier bindings that are created by that code.

+

Environment Record is a specification type used to define the association of |Identifier|s to specific variables and functions, based upon the lexical nesting structure of ECMAScript code. Usually an Environment Record is associated with some specific syntactic structure of ECMAScript code such as a |FunctionDeclaration|, a |BlockStatement|, or a |Catch| clause of a |TryStatement|. Each time such code is evaluated, a new Environment Record is created to record the identifier bindings that are created by that code.

Every Environment Record has an [[OuterEnv]] field, which is either *null* or a reference to an outer Environment Record. This is used to model the logical nesting of Environment Record values. The outer reference of an (inner) Environment Record is a reference to the Environment Record that logically surrounds the inner Environment Record. An outer Environment Record may, of course, have its own outer Environment Record. An Environment Record may serve as the outer environment for multiple inner Environment Records. For example, if a |FunctionDeclaration| contains two nested |FunctionDeclaration|s then the Environment Records of each of the nested functions will have as their outer Environment Record the Environment Record of the current evaluation of the surrounding function.

Environment Records are purely specification mechanisms and need not correspond to any specific artefact of an ECMAScript implementation. It is impossible for an ECMAScript program to directly access or manipulate such values.

@@ -2112,7 +2113,6 @@ contributors: Ron Buckton, Ecma International

The Environment Record abstract class includes the abstract specification methods defined in . These abstract methods have distinct concrete algorithms for each of the concrete subclasses.

- -
Method @@ -2201,15 +2201,14 @@ contributors: Ron Buckton, Ecma International If this Environment Record is associated with a `with` statement, return the with object. Otherwise, return *undefined*.

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.

-

The behaviour of the concrete specification methods for declarative Environment Records is defined by the following algorithms.

+

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 `using` declarations and `await using` declarations that must be disposed when the Evaluation step that constructed the Environment Record has completed.

+

The behaviour of the concrete specification methods for Declarative Environment Records is defined by the following algorithms.

@@ -2221,10 +2220,10 @@ contributors: Ron Buckton, Ecma International

for
-
a declarative Environment Record _envRec_
+
a Declarative Environment Record _envRec_
description
-
It is used to set the bound value of the current binding of the identifier whose name is the value of the argument _N_ to the value of argument _V_. An uninitialized binding for _N_ must already exist.
+
It is used to set the bound value of the current binding of the identifier whose name is _N_ to the value _V_. An uninitialized binding for _N_ must already exist.
1. Assert: _envRec_ must have an uninitialized binding for _N_. @@ -2365,15 +2364,15 @@ contributors: Ron Buckton, Ecma International

FunctionDeclarationInstantiation ( _func_: a function object, - _argumentsList_: unknown, - ) + _argumentsList_: a List of ECMAScript language values, + ): either a normal completion containing ~unused~ or an abrupt completion

description
_func_ is the function object for which the execution context is being established.
-

When an execution context is established for evaluating an ECMAScript function a new function Environment Record is created and bindings for each formal parameter are instantiated in that Environment Record. Each declaration in the function body is also instantiated. If the function's formal parameters do not include any default value initializers then the body declarations are instantiated in the same Environment Record as the parameters. If default value parameter initializers exist, a second Environment Record is created for the body declarations. Formal parameters and functions are initialized as part of FunctionDeclarationInstantiation. All other bindings are initialized during evaluation of the function body.

+

When an execution context is established for evaluating an ECMAScript function a new Function Environment Record is created and bindings for each formal parameter are instantiated in that Environment Record. Each declaration in the function body is also instantiated. If the function's formal parameters do not include any default value initializers then the body declarations are instantiated in the same Environment Record as the parameters. If default value parameter initializers exist, a second Environment Record is created for the body declarations. Formal parameters and functions are initialized as part of FunctionDeclarationInstantiation. All other bindings are initialized during evaluation of the function body.

It performs the following steps when called: