diff --git a/spec.emu b/spec.emu
index df3067d..d7a63af 100644
--- a/spec.emu
+++ b/spec.emu
@@ -1656,7 +1656,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~).
@@ -1674,7 +1674,7 @@ contributors: Ron Buckton, Ecma International
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_.
@@ -2125,8 +2125,8 @@ contributors: Ron Buckton, Ecma International
1. Let _blockEnv_ be NewDeclarativeEnvironment(_oldEnv_).
1. Perform BlockDeclarationInstantiation(|StatementList|, _blockEnv_).
1. Set the running execution context's LexicalEnvironment to _blockEnv_.
- 1. Let _blockValue_ be the result of evaluating |StatementList|.
- 1. Set _blockValue_ to DisposeResources(_blockEnv_, _blockValue_).
+ 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_.
@@ -2242,23 +2242,20 @@ contributors: Ron Buckton, Ecma International
Runtime Semantics: Evaluation
LexicalDeclaration : LetOrConst BindingList `;`
- 1. Let _next_ be the result of evaluating |BindingList|BindingEvaluation of |BindingList| with parameter ~normal~.
- 1. ReturnIfAbrupt(_next_).
+ 1. Perform ? EvaluationBindingEvaluation of |BindingList| with parameter ~normal~.
1. Return ~empty~.
UsingDeclaration : `using` BindingList `;`
- 1. Let _next_ be BindingEvaluation of |BindingList| with parameter ~sync-dispose~.
- 1. ReturnIfAbrupt(_next_).
+ 1. Perform ? BindingEvaluation of |BindingList| with parameter ~sync-dispose~.
1. Return ~empty~.
UsingDeclaration : `using` `await` BindingList `;`
- 1. Let _next_ be BindingEvaluation of |BindingList| with parameter ~async-dispose~.
- 1. ReturnIfAbrupt(_next_).
+ 1. Perform ? BindingEvaluation of |BindingList| with parameter ~async-dispose~.
1. Return ~empty~.
@@ -2266,14 +2263,13 @@ contributors: Ron Buckton, Ecma International
BindingList : BindingList `,` LexicalBinding
- 1. Let _next_ be the result of evaluating |BindingList|.
- 1. ReturnIfAbrupt(_next_).
- 1. Return the result of evaluating |LexicalBinding|.
+ 1. Perform ? Evaluation of |BindingList|.
+ 1. Return ? Evaluation of |LexicalBinding|.
LexicalBinding : BindingIdentifier
- 1. Let _lhs_ be ResolveBinding(StringValue of |BindingIdentifier|).
- 1. Perform ? InitializeReferencedBinding(_lhs_, *undefined*).
+ 1. Let _lhs_ be ! ResolveBinding(StringValue of |BindingIdentifier|).
+ 1. Perform ! InitializeReferencedBinding(_lhs_, *undefined*).
1. Return ~empty~.
@@ -2282,21 +2278,21 @@ contributors: Ron Buckton, Ecma International
LexicalBinding : BindingIdentifier Initializer
1. Let _bindingId_ be StringValue of |BindingIdentifier|.
- 1. Let _lhs_ be Completion(ResolveBinding(_bindingId_)).
+ 1. Let _lhs_ be ! ResolveBinding(_bindingId_).
1. If IsAnonymousFunctionDefinition(|Initializer|) is *true*, then
1. Let _value_ be ? NamedEvaluation of |Initializer| with argument _bindingId_.
1. Else,
- 1. Let _rhs_ be the result of evaluating |Initializer|.
+ 1. Let _rhs_ be ? Evaluation of |Initializer|.
1. Let _value_ be ? GetValue(_rhs_).
- 1. Perform ? InitializeReferencedBinding(_lhs_, _value_).
+ 1. Perform ! InitializeReferencedBinding(_lhs_, _value_).
1. Return ~empty~.
LexicalBinding : BindingPattern Initializer
- 1. Let _rhs_ be the result of evaluating |Initializer|.
+ 1. Let _rhs_ be ? Evaluation of |Initializer|.
1. Let _value_ be ? GetValue(_rhs_).
1. Let _env_ be the running execution context's LexicalEnvironment.
- 1. Return ? BindingInitialization for |BindingPattern| using _value_ and _env_ as the arguments.
+ 1. Return ? BindingInitialization of |BindingPattern| with arguments _value_ and _env_.
@@ -2313,14 +2309,14 @@ contributors: Ron Buckton, Ecma International
BindingList : BindingList `,` LexicalBinding
1. Perform ? BindingEvaluation of |BindingList| with parameter _hint_.
- 1. Perform ? BindingEvaluation of |LexicalBinding| with parameter _hint_.
- 1. Return ~unused~.
+ 1. Return ? BindingEvaluation of |LexicalBinding| with parameter _hint_.
LexicalBinding : BindingIdentifier
1. Assert: _hint_ is ~normal~.
- 1. Let _lhs_ be ? ResolveBinding(StringValue of |BindingIdentifier|).
- 1. Return ? InitializeReferencedBinding(_lhs_, *undefined*, ~normal~).
+ 1. Let _lhs_ be ! ResolveBinding(StringValue of |BindingIdentifier|).
+ 1. Perform ! InitializeReferencedBinding(_lhs_, *undefined*, ~normal~).
+ 1. Return ~unused~.
A static semantics rule ensures that this form of |LexicalBinding| never occurs in a `const` declaration.
@@ -2330,16 +2326,17 @@ contributors: Ron Buckton, Ecma International
1. Let _bindingId_ be StringValue of |BindingIdentifier|.
1. Let _lhs_ be ? ResolveBinding(_bindingId_).
1. If IsAnonymousFunctionDefinition(|Initializer|) is *true*, then
- 1. Let _value_ be NamedEvaluation of |Initializer| with argument _bindingId_.
+ 1. Let _value_ be ? NamedEvaluation of |Initializer| with argument _bindingId_.
1. Else,
- 1. Let _rhs_ be the result of evaluating |Initializer|.
+ 1. Let _rhs_ be ? Evaluation of |Initializer|.
1. Let _value_ be ? GetValue(_rhs_).
- 1. Return ? InitializeReferencedBinding(_lhs_, _value_, _hint_).
+ 1. Perform ? InitializeReferencedBinding(_lhs_, _value_, _hint_).
+ 1. Return ~unused~.
LexicalBinding : BindingPattern Initializer
1. Assert: _hint_ is ~normal~.
- 1. Let _rhs_ be the result of evaluating |Initializer|.
+ 1. Let _rhs_ be ? Evaluation of |Initializer|.
1. Let _value_ be ? GetValue(_rhs_).
1. Let _env_ be the running execution context's LexicalEnvironment.
1. Return ? BindingInitialization of |BindingPattern| with arguments _value_ and _env_.
@@ -2388,7 +2385,7 @@ contributors: Ron Buckton, Ecma International
1. Let _v_ be ? GetV(_value_, _propertyName_).
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_.
@@ -2401,7 +2398,7 @@ contributors: Ron Buckton, Ecma International
1. If IsAnonymousFunctionDefinition(|Initializer|) is *true*, then
1. Set _v_ to ? NamedEvaluation for |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~).
@@ -2427,15 +2424,18 @@ contributors: Ron Buckton, Ecma International
ForStatement : `for` `(` Expression? `;` Expression? `;` Expression? `)` Statement
1. If the first |Expression| is present, then
- 1. Let _exprRef_ be the result of evaluating the first |Expression|.
+ 1. Let _exprRef_ be ? Evaluation of the first |Expression|.
1. Perform ? GetValue(_exprRef_).
- 1. Return ? ForBodyEvaluation(the second |Expression|, the third |Expression|, |Statement|, « », _labelSet_).
+ 1. If the second |Expression| is present, let _test_ be the second |Expression|; otherwise, let _test_ be ~empty~.
+ 1. If the third |Expression| is present, let _increment_ be the third |Expression|; otherwise, let _increment_ be ~empty~.
+ 1. Return ? ForBodyEvaluation(_test_, _increment_, |Statement|, « », _labelSet_).
ForStatement : `for` `(` `var` VariableDeclarationList `;` Expression? `;` Expression? `)` Statement
- 1. Let _varDcl_ be the result of evaluating |VariableDeclarationList|.
- 1. ReturnIfAbrupt(_varDcl_).
- 1. Return ? ForBodyEvaluation(the first |Expression|, the second |Expression|, |Statement|, « », _labelSet_).
+ 1. Perform ? Evaluation of |VariableDeclarationList|.
+ 1. If the first |Expression| is present, let _test_ be the first |Expression|; otherwise, let _test_ be ~empty~.
+ 1. If the second |Expression| is present, let _increment_ be the second |Expression|; otherwise, let _increment_ be ~empty~.
+ 1. Return ? ForBodyEvaluation(_test_, _increment_, |Statement|, « », _labelSet_).
ForStatement : `for` `(` LexicalDeclaration Expression? `;` Expression? `)` Statement
@@ -2449,14 +2449,18 @@ contributors: Ron Buckton, Ecma International
1. Else,
1. Perform ! _loopEnv_.CreateMutableBinding(_dn_, *false*).
1. Set the running execution context's LexicalEnvironment to _loopEnv_.
- 1. Let _forDcl_ be the result of evaluating |LexicalDeclaration|.
+ 1. Let _forDcl_ be Completion(Evaluation of |LexicalDeclaration|).
1. If _forDcl_ is an abrupt completion, then
- 1. Set _forDcl_ to DisposeResources(_loopEnv_, _forDcl_).
+ 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_; otherwise let _perIterationLets_ be a new empty List.
- 1. Let _bodyResult_ be Completion(ForBodyEvaluation(the first |Expression|, the second |Expression|, |Statement|, _perIterationLets_, _labelSet_)).
- 1. Set _bodyResult_ to DisposeResources(_loopEnv_, _bodyResult_).
+ 1. If the first |Expression| is present, let _test_ be the first |Expression|; otherwise, let _test_ be ~empty~.
+ 1. If the second |Expression| is present, let _increment_ be the second |Expression|; otherwise, 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_.
@@ -2552,13 +2556,24 @@ contributors: Ron Buckton, Ecma International
1. Repeat,
1. Let _nextResult_ be ? Call(_iteratorRecord_.[[NextMethod]], _iteratorRecord_.[[Iterator]]).
1. If _iteratorKind_ is ~async~, set _nextResult_ to ? Await(_nextResult_).
- 1. If Type(_nextResult_) is not Object, throw a *TypeError* exception.
+ 1. If _nextResult_ is not an Object, throw a *TypeError* exception.
1. Let _done_ be ? IteratorComplete(_nextResult_).
1. If _done_ is *true*, return _V_.
1. Let _nextValue_ be ? IteratorValue(_nextResult_).
1. If _lhsKind_ is either ~assignment~ or ~varBinding~, then
- 1. If _destructuring_ is *false*, then
- 1. Let _lhsRef_ be the result of evaluating _lhs_. (It may be evaluated repeatedly.)
+ 1. If _destructuring_ is *true*, then
+ 1. If _lhsKind_ is ~assignment~, then
+ 1. Let _status_ be Completion(DestructuringAssignmentEvaluation of _assignmentPattern_ with argument _nextValue_).
+ 1. Else,
+ 1. Assert: _lhsKind_ is ~varBinding~.
+ 1. Assert: _lhs_ is a |ForBinding|.
+ 1. Let _status_ be Completion(BindingInitialization of _lhs_ with arguments _nextValue_ and *undefined*).
+ 1. Else,
+ 1. Let _lhsRef_ be Completion(Evaluation of _lhs_). (It may be evaluated repeatedly.)
+ 1. If _lhsRef_ is an abrupt completion, then
+ 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 ~lexicalBinding~.
@@ -2566,30 +2581,21 @@ contributors: Ron Buckton, Ecma International
1. Let _iterationEnv_ be NewDeclarativeEnvironment(_oldEnv_).
1. Perform ForDeclarationBindingInstantiation of _lhs_ with argument _iterationEnv_.
1. Set the running execution context's LexicalEnvironment to _iterationEnv_.
- 1. If _destructuring_ is *false*, then
+ 1. If _destructuring_ is *true*, then
+ 1. Let _status_ be Completion(ForDeclarationBindingInitialization of _lhs_ with arguments _nextValue_ and _iterationEnv_).
+ 1. Else,
1. Assert: _lhs_ binds a single name.
1. Let _lhsName_ be the sole element of BoundNames of _lhs_.
1. Let _lhsRef_ be ! ResolveBinding(_lhsName_).
- 1. If _destructuring_ is *false*, then
- 1. If _lhsRef_ is an abrupt completion, then
- 1. Let _status_ be _lhsRef_.
- 1. Else if _lhsKind_ is ~lexicalBinding~, then
- 1. Let _status_ be Completion(InitializeReferencedBinding(_lhsRef_, _nextValue_, _hint_)).
- 1. Else,
- 1. Let _status_ be Completion(PutValue(_lhsRef_, _nextValue_)).
- 1. Else,
- 1. If _lhsKind_ is ~assignment~, then
- 1. Let _status_ be Completion(DestructuringAssignmentEvaluation of _assignmentPattern_ with argument _nextValue_).
- 1. Else if _lhsKind_ is ~varBinding~, then
- 1. Assert: _lhs_ is a |ForBinding|.
- 1. Let _status_ be Completion(BindingInitialization of _lhs_ with arguments _nextValue_ and *undefined*).
- 1. Else,
- 1. Assert: _lhsKind_ is ~lexicalBinding~.
- 1. Assert: _lhs_ is a |ForDeclaration|.
- 1. Let _status_ be Completion(ForDeclarationBindingInitialization of _lhs_ with arguments _nextValue_ and _iterationEnv_).
+ 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. If _status_ is an abrupt completion, then
1. If _iterationEnv_ is not *undefined*, then
- 1. Set _status_ to DisposeResources(_iterationEnv_, _status_).
+ 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 _iteratorKind_ is ~async~, return ? AsyncIteratorClose(_iteratorRecord_, _status_).
1. If _iterationKind_ is ~enumerate~, then
@@ -2597,9 +2603,9 @@ contributors: Ron Buckton, Ecma International
1. Else,
1. Assert: _iterationKind_ is ~iterate~.
1. Return ? IteratorClose(_iteratorRecord_, _status_).
- 1. Let _result_ be the result of evaluating _stmt_.
+ 1. Let _result_ be Completion(Evaluation of _stmt_).
1. If _iterationEnv_ is not *undefined*, then
- 1. Set _result_ to DisposeResources(_iterationEnv_, _result_).
+ 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. If _iterationKind_ is ~enumerate~, then
@@ -2622,15 +2628,15 @@ contributors: Ron Buckton, Ecma International
Runtime Semantics: Evaluation
SwitchStatement : `switch` `(` Expression `)` CaseBlock
- 1. Let _exprRef_ be the result of evaluating |Expression|.
+ 1. Let _exprRef_ be ? Evaluation of |Expression|.
1. Let _switchValue_ be ? GetValue(_exprRef_).
1. Let _oldEnv_ be the running execution context's LexicalEnvironment.
1. Let _blockEnv_ be NewDeclarativeEnvironment(_oldEnv_).
1. Perform BlockDeclarationInstantiation(|CaseBlock|, _blockEnv_).
1. Set the running execution context's LexicalEnvironment to _blockEnv_.
1. Let _R_ be Completion(CaseBlockEvaluation of |CaseBlock| with argument _switchValue_).
- 1. Let _env_ be _blockEnv_'s LexicalEnvironment.
- 1. Set _R_ to DisposeResources(_env_, _R_).
+ 1. Set _R_ to Completion(DisposeResources(_blockEnv_.[[DisposeCapability]], _R_)).
+ 1. Assert: If _R_.[[Type]] is ~normal~, then _R_.[[Value]] is not ~empty~.
1. Set the running execution context's LexicalEnvironment to _oldEnv_.
1. Return _R_.
@@ -2660,10 +2666,10 @@ contributors: Ron Buckton, Ecma International
FunctionBody : FunctionStatementList
1. Perform ? FunctionDeclarationInstantiation(_functionObject_, _argumentsList_).
- 1. Return the result of evaluating |FunctionStatementList|.
- 1. Let _result_ be result of evaluating |FunctionStatementList|.
+ 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_, _result_).
+ 1. Return ? DisposeResources(_env_.[[DisposeCapability]], _result_).
@@ -2692,13 +2698,13 @@ contributors: Ron Buckton, Ecma International
1. Set _name_ to StringValue of |BindingIdentifier|.
1. Let _scope_ be the running execution context's LexicalEnvironment.
1. Let _funcEnv_ be NewDeclarativeEnvironment(_scope_).
- 1. Perform _funcEnv_.CreateImmutableBinding(_name_, *false*).
+ 1. Perform ! _funcEnv_.CreateImmutableBinding(_name_, *false*).
1. Let _privateScope_ be the running execution context's PrivateEnvironment.
1. Let _sourceText_ be the source text matched by |FunctionExpression|.
1. Let _closure_ be OrdinaryFunctionCreate(%Function.prototype%, _sourceText_, |FormalParameters|, |FunctionBody|, ~non-lexical-this~, _funcEnv_, _privateScope_).
1. Perform SetFunctionName(_closure_, _name_).
1. Perform MakeConstructor(_closure_).
- 1. Perform _funcEnv_.InitializeBinding(_name_, _closure_, ~normal~).
+ 1. Perform ! _funcEnv_.InitializeBinding(_name_, _closure_, ~normal~).
1. Return _closure_.
@@ -2725,8 +2731,8 @@ contributors: Ron Buckton, Ecma International
1. Let _sourceText_ be the source text matched by |GeneratorExpression|.
1. Let _closure_ be OrdinaryFunctionCreate(%GeneratorFunction.prototype%, _sourceText_, |FormalParameters|, |GeneratorBody|, ~non-lexical-this~, _scope_, _privateScope_).
1. Perform SetFunctionName(_closure_, _name_).
- 1. Let _prototype_ be ! OrdinaryObjectCreate(%GeneratorFunction.prototype.prototype%).
- 1. Perform DefinePropertyOrThrow(_closure_, *"prototype"*, PropertyDescriptor { [[Value]]: _prototype_, [[Writable]]: *true*, [[Enumerable]]: *false*, [[Configurable]]: *false* }).
+ 1. Let _prototype_ be OrdinaryObjectCreate(%GeneratorFunction.prototype.prototype%).
+ 1. Perform ! DefinePropertyOrThrow(_closure_, *"prototype"*, PropertyDescriptor { [[Value]]: _prototype_, [[Writable]]: *true*, [[Enumerable]]: *false*, [[Configurable]]: *false* }).
1. Return _closure_.
GeneratorExpression : `function` `*` BindingIdentifier `(` FormalParameters `)` `{` GeneratorBody `}`
@@ -2735,14 +2741,14 @@ contributors: Ron Buckton, Ecma International
1. Set _name_ to StringValue of |BindingIdentifier|.
1. Let _scope_ be the running execution context's LexicalEnvironment.
1. Let _funcEnv_ be NewDeclarativeEnvironment(_scope_).
- 1. Perform _funcEnv_.CreateImmutableBinding(_name_, *false*).
+ 1. Perform ! _funcEnv_.CreateImmutableBinding(_name_, *false*).
1. Let _privateScope_ be the running execution context's PrivateEnvironment.
1. Let _sourceText_ be the source text matched by |GeneratorExpression|.
1. Let _closure_ be OrdinaryFunctionCreate(%GeneratorFunction.prototype%, _sourceText_, |FormalParameters|, |GeneratorBody|, ~non-lexical-this~, _funcEnv_, _privateScope_).
1. Perform SetFunctionName(_closure_, _name_).
- 1. Let _prototype_ be ! OrdinaryObjectCreate(%GeneratorFunction.prototype.prototype%).
- 1. Perform DefinePropertyOrThrow(_closure_, *"prototype"*, PropertyDescriptor { [[Value]]: _prototype_, [[Writable]]: *true*, [[Enumerable]]: *false*, [[Configurable]]: *false* }).
- 1. Perform _funcEnv_.InitializeBinding(_name_, _closure_, ~normal~).
+ 1. Let _prototype_ be OrdinaryObjectCreate(%GeneratorFunction.prototype.prototype%).
+ 1. Perform ! DefinePropertyOrThrow(_closure_, *"prototype"*, PropertyDescriptor { [[Value]]: _prototype_, [[Writable]]: *true*, [[Enumerable]]: *false*, [[Configurable]]: *false* }).
+ 1. Perform ! _funcEnv_.InitializeBinding(_name_, _closure_, ~normal~).
1. Return _closure_.
@@ -2770,9 +2776,9 @@ contributors: Ron Buckton, Ecma International
1. Let _scope_ be the LexicalEnvironment of the running execution context.
1. Let _privateScope_ be the running execution context's PrivateEnvironment.
1. Let _sourceText_ be the source text matched by |AsyncGeneratorExpression|.
- 1. Let _closure_ be ! OrdinaryFunctionCreate(%AsyncGeneratorFunction.prototype%, _sourceText_, |FormalParameters|, |AsyncGeneratorBody|, ~non-lexical-this~, _scope_, _privateScope_).
+ 1. Let _closure_ be OrdinaryFunctionCreate(%AsyncGeneratorFunction.prototype%, _sourceText_, |FormalParameters|, |AsyncGeneratorBody|, ~non-lexical-this~, _scope_, _privateScope_).
1. Perform SetFunctionName(_closure_, _name_).
- 1. Let _prototype_ be ! OrdinaryObjectCreate(%AsyncGeneratorFunction.prototype.prototype%).
+ 1. Let _prototype_ be OrdinaryObjectCreate(%AsyncGeneratorFunction.prototype.prototype%).
1. Perform ! DefinePropertyOrThrow(_closure_, *"prototype"*, PropertyDescriptor { [[Value]]: _prototype_, [[Writable]]: *true*, [[Enumerable]]: *false*, [[Configurable]]: *false* }).
1. Return _closure_.
@@ -2783,13 +2789,13 @@ contributors: Ron Buckton, Ecma International
1. Assert: _name_ is not present.
1. Set _name_ to StringValue of |BindingIdentifier|.
1. Let _scope_ be the running execution context's LexicalEnvironment.
- 1. Let _funcEnv_ be ! NewDeclarativeEnvironment(_scope_).
+ 1. Let _funcEnv_ be NewDeclarativeEnvironment(_scope_).
1. Perform ! _funcEnv_.CreateImmutableBinding(_name_, *false*).
1. Let _privateScope_ be the running execution context's PrivateEnvironment.
1. Let _sourceText_ be the source text matched by |AsyncGeneratorExpression|.
- 1. Let _closure_ be ! OrdinaryFunctionCreate(%AsyncGeneratorFunction.prototype%, _sourceText_, |FormalParameters|, |AsyncGeneratorBody|, ~non-lexical-this~, _funcEnv_, _privateScope_).
- 1. Perform ! SetFunctionName(_closure_, _name_).
- 1. Let _prototype_ be ! OrdinaryObjectCreate(%AsyncGeneratorFunction.prototype.prototype%).
+ 1. Let _closure_ be OrdinaryFunctionCreate(%AsyncGeneratorFunction.prototype%, _sourceText_, |FormalParameters|, |AsyncGeneratorBody|, ~non-lexical-this~, _funcEnv_, _privateScope_).
+ 1. Perform SetFunctionName(_closure_, _name_).
+ 1. Let _prototype_ be OrdinaryObjectCreate(%AsyncGeneratorFunction.prototype.prototype%).
1. Perform ! DefinePropertyOrThrow(_closure_, *"prototype"*, PropertyDescriptor { [[Value]]: _prototype_, [[Writable]]: *true*, [[Enumerable]]: *false*, [[Configurable]]: *false* }).
1. Perform ! _funcEnv_.InitializeBinding(_name_, _closure_, ~normal~).
1. Return _closure_.
@@ -2814,10 +2820,10 @@ contributors: Ron Buckton, Ecma International
ClassStaticBlockBody : ClassStaticBlockStatementList
1. Perform ? FunctionDeclarationInstantiation(_functionObject_, « »).
- 1. Return the result of evaluating |ClassStaticBlockStatementList|.
- 1. Let _result_ be result of evaluating |ClassStaticBlockStatementList|.
+ 1. Return ? Evaluation of |ClassStaticBlockStatementList|.
+ 1. Let _result_ be Completion(Evaluation of |ClassStaticBlockStatementList|).
1. Let _env_ be the running execution context's LexicalEnvironment.
- 1. Return ? DisposeResources(_env_, _result_).
+ 1. Return ? DisposeResources(_env_.[[DisposeCapability]], _result_).
@@ -2838,9 +2844,9 @@ contributors: Ron Buckton, Ecma International
ClassTail : ClassHeritage? `{` ClassBody? `}`
1. Let _env_ be the LexicalEnvironment of the running execution context.
- 1. Let _classScope_ be NewDeclarativeEnvironment(_env_).
+ 1. Let _classEnv_ be NewDeclarativeEnvironment(_env_).
1. If _classBinding_ is not *undefined*, then
- 1. Perform _classScope_.CreateImmutableBinding(_classBinding_, *true*).
+ 1. Perform ! _classEnv_.CreateImmutableBinding(_classBinding_, *true*).
1. Let _outerPrivateEnvironment_ be the running execution context's PrivateEnvironment.
1. Let _classPrivateEnvironment_ be NewPrivateEnvironment(_outerPrivateEnvironment_).
1. If |ClassBody?| is present, then
@@ -2854,23 +2860,23 @@ contributors: Ron Buckton, Ecma International
1. Let _protoParent_ be %Object.prototype%.
1. Let _constructorParent_ be %Function.prototype%.
1. Else,
- 1. Set the running execution context's LexicalEnvironment to _classScope_.
+ 1. Set the running execution context's LexicalEnvironment to _classEnv_.
1. NOTE: The running execution context's PrivateEnvironment is _outerPrivateEnvironment_ when evaluating |ClassHeritage|.
- 1. Let _superclassRef_ be the result of evaluating |ClassHeritage|.
+ 1. Let _superclassRef_ be Completion(Evaluation of |ClassHeritage|).
1. Set the running execution context's LexicalEnvironment to _env_.
- 1. Let _superclass_ be ? GetValue(_superclassRef_).
+ 1. Let _superclass_ be ? GetValue(? _superclassRef_).
1. If _superclass_ is *null*, then
1. Let _protoParent_ be *null*.
1. Let _constructorParent_ be %Function.prototype%.
1. Else if IsConstructor(_superclass_) is *false*, throw a *TypeError* exception.
1. Else,
1. Let _protoParent_ be ? Get(_superclass_, *"prototype"*).
- 1. If Type(_protoParent_) is neither Object nor Null, throw a *TypeError* exception.
+ 1. If _protoParent_ is not an Object and _protoParent_ is not *null*, throw a *TypeError* exception.
1. Let _constructorParent_ be _superclass_.
- 1. Let _proto_ be ! OrdinaryObjectCreate(_protoParent_).
+ 1. Let _proto_ be OrdinaryObjectCreate(_protoParent_).
1. If |ClassBody?| is not present, let _constructor_ be ~empty~.
1. Else, let _constructor_ be ConstructorMethod of |ClassBody|.
- 1. Set the running execution context's LexicalEnvironment to _classScope_.
+ 1. Set the running execution context's LexicalEnvironment to _classEnv_.
1. Set the running execution context's PrivateEnvironment to _classPrivateEnvironment_.
1. If _constructor_ is ~empty~, then
1. Let _defaultConstructor_ be a new Abstract Closure with no parameters that captures nothing and performs the following steps when called:
@@ -2887,15 +2893,15 @@ contributors: Ron Buckton, Ecma International
1. Let _result_ be ? OrdinaryCreateFromConstructor(NewTarget, *"%Object.prototype%"*).
1. Perform ? InitializeInstanceElements(_result_, _F_).
1. Return _result_.
- 1. Let _F_ be ! CreateBuiltinFunction(_defaultConstructor_, 0, _className_, « [[ConstructorKind]], [[SourceText]] », the current Realm Record, _constructorParent_).
+ 1. Let _F_ be CreateBuiltinFunction(_defaultConstructor_, 0, _className_, « [[ConstructorKind]], [[SourceText]] », the current Realm Record, _constructorParent_).
1. Else,
1. Let _constructorInfo_ be ! DefineMethod of _constructor_ with arguments _proto_ and _constructorParent_.
1. Let _F_ be _constructorInfo_.[[Closure]].
- 1. Perform ! MakeClassConstructor(_F_).
- 1. Perform ! SetFunctionName(_F_, _className_).
- 1. Perform ! MakeConstructor(_F_, *false*, _proto_).
+ 1. Perform MakeClassConstructor(_F_).
+ 1. Perform SetFunctionName(_F_, _className_).
+ 1. Perform MakeConstructor(_F_, *false*, _proto_).
1. If |ClassHeritage?| is present, set _F_.[[ConstructorKind]] to ~derived~.
- 1. Perform ! CreateMethodProperty(_proto_, *"constructor"*, _F_).
+ 1. Perform CreateMethodProperty(_proto_, *"constructor"*, _F_).
1. If |ClassBody?| is not present, let _elements_ be a new empty List.
1. Else, let _elements_ be NonConstructorElements of |ClassBody|.
1. Let _instancePrivateMethods_ be a new empty List.
@@ -2904,13 +2910,13 @@ contributors: Ron Buckton, Ecma International
1. Let _staticElements_ be a new empty List.
1. For each |ClassElement| _e_ of _elements_, do
1. If IsStatic of _e_ is *false*, then
- 1. Let _element_ be ClassElementEvaluation of _e_ with argument _proto_.
+ 1. Let _element_ be Completion(ClassElementEvaluation of _e_ with argument _proto_).
1. Else,
- 1. Let _element_ be ClassElementEvaluation of _e_ with argument _F_.
+ 1. Let _element_ be Completion(ClassElementEvaluation of _e_ with argument _F_).
1. If _element_ is an abrupt completion, then
1. Set the running execution context's LexicalEnvironment to _env_.
1. Set the running execution context's PrivateEnvironment to _outerPrivateEnvironment_.
- 1. Return Completion(_element_).
+ 1. Return ? _element_.
1. Set _element_ to _element_.[[Value]].
1. If _element_ is a PrivateElement, then
1. Assert: _element_.[[Kind]] is either ~method~ or ~accessor~.
@@ -2933,20 +2939,20 @@ contributors: Ron Buckton, Ecma International
1. Append _element_ to _staticElements_.
1. Set the running execution context's LexicalEnvironment to _env_.
1. If _classBinding_ is not *undefined*, then
- 1. Perform _classScope_.InitializeBinding(_classBinding_, _F_, ~normal~).
+ 1. Perform ! _classScope_.InitializeBinding(_classBinding_, _F_, ~normal~).
1. Set _F_.[[PrivateMethods]] to _instancePrivateMethods_.
1. Set _F_.[[Fields]] to _instanceFields_.
1. For each PrivateElement _method_ of _staticPrivateMethods_, do
1. Perform ! PrivateMethodOrAccessorAdd(_F_, _method_).
1. For each element _elementRecord_ of _staticElements_, do
1. If _elementRecord_ is a ClassFieldDefinition Record, then
- 1. Let _result_ be DefineField(_F_, _elementRecord_).
+ 1. Let _result_ be Completion(DefineField(_F_, _elementRecord_)).
1. Else,
1. Assert: _elementRecord_ is a ClassStaticBlockDefinition Record.
- 1. Let _result_ be ? Call(_elementRecord_.[[BodyFunction]], _F_).
+ 1. Let _result_ be Completion(Call(_elementRecord_.[[BodyFunction]], _F_)).
1. If _result_ is an abrupt completion, then
1. Set the running execution context's PrivateEnvironment to _outerPrivateEnvironment_.
- 1. Return _result_.
+ 1. Return ? _result_.
1. Set the running execution context's PrivateEnvironment to _outerPrivateEnvironment_.
1. Return _F_.
@@ -2972,7 +2978,7 @@ contributors: Ron Buckton, Ecma International
1. Let _scope_ be the LexicalEnvironment of the running execution context.
1. Let _privateScope_ be the running execution context's PrivateEnvironment.
1. Let _sourceText_ be the source text matched by |AsyncFunctionExpression|.
- 1. Let _closure_ be ! OrdinaryFunctionCreate(%AsyncFunction.prototype%, _sourceText_, |FormalParameters|, |AsyncFunctionBody|, ~non-lexical-this~, _scope_, _privateScope_).
+ 1. Let _closure_ be OrdinaryFunctionCreate(%AsyncFunction.prototype%, _sourceText_, |FormalParameters|, |AsyncFunctionBody|, ~non-lexical-this~, _scope_, _privateScope_).
1. Perform SetFunctionName(_closure_, _name_).
1. Return _closure_.
@@ -2983,12 +2989,12 @@ contributors: Ron Buckton, Ecma International
1. Assert: _name_ is not present.
1. Set _name_ to StringValue of |BindingIdentifier|.
1. Let _scope_ be the LexicalEnvironment of the running execution context.
- 1. Let _funcEnv_ be ! NewDeclarativeEnvironment(_scope_).
+ 1. Let _funcEnv_ be NewDeclarativeEnvironment(_scope_).
1. Perform ! _funcEnv_.CreateImmutableBinding(_name_, *false*).
1. Let _privateScope_ be the running execution context's PrivateEnvironment.
1. Let _sourceText_ be the source text matched by |AsyncFunctionExpression|.
- 1. Let _closure_ be ! OrdinaryFunctionCreate(%AsyncFunction.prototype%, _sourceText_, |FormalParameters|, |AsyncFunctionBody|, ~non-lexical-this~, _funcEnv_, _privateScope_).
- 1. Perform ! SetFunctionName(_closure_, _name_).
+ 1. Let _closure_ be OrdinaryFunctionCreate(%AsyncFunction.prototype%, _sourceText_, |FormalParameters|, |AsyncFunctionBody|, ~non-lexical-this~, _funcEnv_, _privateScope_).
+ 1. Perform SetFunctionName(_closure_, _name_).
1. Perform ! _funcEnv_.InitializeBinding(_name_, _closure_, ~normal~).
1. Return _closure_.
@@ -3001,10 +3007,10 @@ contributors: Ron Buckton, Ecma International
Tail Position Calls
-
+
Static Semantics: HasCallInTailPosition (
- _call_: unknown,
+ _call_: a |CallExpression| Parse Node, a |MemberExpression| Parse Node, or an |OptionalChain| Parse Node,
): a Boolean
@@ -3239,7 +3419,7 @@ contributors: Ron Buckton, Ecma International
Source Text Module Records
- InitializeEnvironment ( )
+ InitializeEnvironment ( ): either a normal completion containing ~unused~ or a throw completion
@@ -3323,15 +3502,15 @@ contributors: Ron Buckton, Ecma International
1. Set the Realm of _moduleContext_ to _module_.[[Realm]].
1. Set the ScriptOrModule of _moduleContext_ to _module_.
1. Assert: _module_ has been linked and declarations in its module environment have been instantiated.
- 1. Set the VariableEnvironment of _moduleContext_ to _module_.[[Environment]].
- 1. Set the LexicalEnvironment of _moduleContext_ to _module_.[[Environment]].
- 1. Suspend the currently running execution context.
+ 1. Let _env_ be _module_.[[Environment]].
+ 1. Set the VariableEnvironment of _moduleContext_ to _env_.
+ 1. Set the LexicalEnvironment of _moduleContext_ to _env_.
+ 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 the result of evaluating _module_.[[ECMAScriptCode]].
- 1. Let _env_ be _moduleContext_'s LexicalEnvironment.
- 1. Set _result_ to DisposeResources(_env_, _result_).
+ 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
@@ -3408,17 +3587,17 @@ contributors: Ron Buckton, Ecma International
1. Let _varNames_ be the VarDeclaredNames of _body_.
1. Let _varDeclarations_ be the VarScopedDeclarations of _body_.
1. If _strict_ is *false*, then
- 1. If _varEnv_ is a global Environment Record, then
+ 1. If _varEnv_ is a Global Environment Record, then
1. For each element _name_ of _varNames_, do
1. If _varEnv_.HasLexicalDeclaration(_name_) is *true*, throw a *SyntaxError* exception.
1. NOTE: `eval` will not create a global var declaration that would be shadowed by a global lexical declaration.
1. Let _thisEnv_ be _lexEnv_.
1. Assert: The following loop will terminate.
1. Repeat, while _thisEnv_ is not the same as _varEnv_,
- 1. If _thisEnv_ is not an object Environment Record, then
+ 1. If _thisEnv_ is not an Object Environment Record, then
1. NOTE: The environment of with statements cannot contain any lexical declaration so it doesn't need to be checked for var/let hoisting conflicts.
1. For each element _name_ of _varNames_, do
- 1. If _thisEnv_.HasBinding(_name_) is *true*, then
+ 1. If ! _thisEnv_.HasBinding(_name_) is *true*, then
1. [id="step-evaldeclarationinstantiation-throw-duplicate-binding"] Throw a *SyntaxError* exception.
1. NOTE: Annex defines alternate semantics for the above step.
1. NOTE: A direct eval will not hoist var declaration over a like-named lexical declaration.
@@ -3438,7 +3617,7 @@ contributors: Ron Buckton, Ecma International
1. NOTE: If there are multiple function declarations for the same name, the last declaration is used.
1. Let _fn_ be the sole element of the BoundNames of _d_.
1. If _fn_ is not an element of _declaredFunctionNames_, then
- 1. If _varEnv_ is a global Environment Record, then
+ 1. If _varEnv_ is a Global Environment Record, then
1. Let _fnDefinable_ be ? _varEnv_.CanDeclareGlobalFunction(_fn_).
1. If _fnDefinable_ is *false*, throw a *TypeError* exception.
1. Append _fn_ to _declaredFunctionNames_.
@@ -3449,12 +3628,12 @@ contributors: Ron Buckton, Ecma International
1. If _d_ is a |VariableDeclaration|, a |ForBinding|, or a |BindingIdentifier|, then
1. For each String _vn_ of the BoundNames of _d_, do
1. If _vn_ is not an element of _declaredFunctionNames_, then
- 1. If _varEnv_ is a global Environment Record, then
+ 1. If _varEnv_ is a Global Environment Record, then
1. Let _vnDefinable_ be ? _varEnv_.CanDeclareGlobalVar(_vn_).
1. If _vnDefinable_ is *false*, throw a *TypeError* exception.
1. If _vn_ is not an element of _declaredVarNames_, then
1. Append _vn_ to _declaredVarNames_.
- 1. [id="step-evaldeclarationinstantiation-post-validation"] NOTE: No abnormal terminations occur after this algorithm step unless _varEnv_ is a global Environment Record and the global object is a Proxy exotic object.
+ 1. [id="step-evaldeclarationinstantiation-post-validation"] NOTE: No abnormal terminations occur after this algorithm step unless _varEnv_ is a Global Environment Record and the global object is a Proxy exotic object.
1. Let _lexDeclarations_ be the LexicallyScopedDeclarations of _body_.
1. For each element _d_ of _lexDeclarations_, do
1. NOTE: Lexically declared names are only instantiated here but not initialized.
@@ -3466,26 +3645,26 @@ contributors: Ron Buckton, Ecma International
1. For each Parse Node _f_ of _functionsToInitialize_, do
1. Let _fn_ be the sole element of the BoundNames of _f_.
1. Let _fo_ be InstantiateFunctionObject of _f_ with arguments _lexEnv_ and _privateEnv_.
- 1. If _varEnv_ is a global Environment Record, then
+ 1. If _varEnv_ is a Global Environment Record, then
1. Perform ? _varEnv_.CreateGlobalFunctionBinding(_fn_, _fo_, *true*).
1. Else,
- 1. Let _bindingExists_ be _varEnv_.HasBinding(_fn_).
+ 1. Let _bindingExists_ be ! _varEnv_.HasBinding(_fn_).
1. If _bindingExists_ is *false*, then
- 1. Let _status_ be ! _varEnv_.CreateMutableBinding(_fn_, *true*).
- 1. Assert: _status_ is not an abrupt completion because of validation preceding step .
- 1. Perform ! _varEnv_.InitializeBinding(_fn_, _fo_, ~normal~).
+ 1. NOTE: The following invocation cannot return an abrupt completion because of the validation preceding step .
+ 1. Perform ! _varEnv_.CreateMutableBinding(_fn_, *true*).
+ 1. Perform ! _varEnv_.InitializeBinding(_fn_, _fo_, ~normal~).
1. Else,
1. Perform ! _varEnv_.SetMutableBinding(_fn_, _fo_, *false*).
1. For each String _vn_ of _declaredVarNames_, do
- 1. If _varEnv_ is a global Environment Record, then
+ 1. If _varEnv_ is a Global Environment Record, then
1. Perform ? _varEnv_.CreateGlobalVarBinding(_vn_, *true*).
1. Else,
- 1. Let _bindingExists_ be _varEnv_.HasBinding(_vn_).
+ 1. Let _bindingExists_ be ! _varEnv_.HasBinding(_vn_).
1. If _bindingExists_ is *false*, then
- 1. Let _status_ be ! _varEnv_.CreateMutableBinding(_vn_, *true*).
- 1. Assert: _status_ is not an abrupt completion because of validation preceding step .
- 1. Perform ! _varEnv_.InitializeBinding(_vn_, *undefined*, ~normal~).
- 1. Return NormalCompletion(~empty~).
+ 1. NOTE: The following invocation cannot return an abrupt completion because of the validation preceding step .
+ 1. Perform ! _varEnv_.CreateMutableBinding(_vn_, *true*).
+ 1. Perform ! _varEnv_.InitializeBinding(_vn_, *undefined*, ~normal~).
+ 1. Return ~unused~.
An alternative version of this algorithm is described in .
@@ -4163,7 +4342,7 @@ contributors: Ron Buckton, Ecma International
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_, _result_).
+ 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,
@@ -4207,7 +4386,7 @@ contributors: Ron Buckton, Ecma International
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_, _result_).
+ 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*).
@@ -4246,7 +4425,7 @@ contributors: Ron Buckton, Ecma International
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_, _result_).
+ 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