From 4e44be67d4b6f0d98aed8aa1e4eff14169390eff Mon Sep 17 00:00:00 2001 From: Kevin Gibbons Date: Wed, 28 Apr 2021 17:03:38 -0700 Subject: [PATCH 1/3] Editorial: describe behavior for algorithms without a "Return" --- spec.html | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/spec.html b/spec.html index 511a46d609..676d3faf28 100644 --- a/spec.html +++ b/spec.html @@ -826,8 +826,10 @@

Implicit Completion Values

A “return” statement without a value in an algorithm step means the same thing as:

- 1. Return NormalCompletion(*undefined*). + 1. Return NormalCompletion(~unused~). +

In the above step, ~unused~ is a special value which is never directly consumed.

+

If all steps in an abstract operation have been executed without returning, the abstract operation behaves as though there were an additional step reading "Return." after the existing steps.

Any reference to a Completion Record value that is in a context that does not explicitly require a complete Completion Record value is equivalent to an explicit reference to the [[Value]] field of the Completion Record value unless the Completion Record is an abrupt completion.

@@ -3525,7 +3527,7 @@

The Completion Record Specification Type

[[Value]] - any ECMAScript language value or ~empty~ + any ECMAScript language value, ~empty~, or ~unused~ The value that was produced. @@ -3782,7 +3784,7 @@

PutValue ( _V_, _W_ )

1. [id="step-putvalue-toobject"] Let _baseObj_ be ! ToObject(_V_.[[Base]]). 1. Let _succeeded_ be ? _baseObj_.[[Set]](_V_.[[ReferencedName]], _W_, GetThisValue(_V_)). 1. If _succeeded_ is *false* and _V_.[[Strict]] is *true*, throw a *TypeError* exception. - 1. Return. + 1. Return *undefined*. 1. Else, 1. Let _base_ be _V_.[[Base]]. 1. Assert: _base_ is an Environment Record. @@ -39484,8 +39486,7 @@

AsyncFunctionStart ( _promiseCapability_, _asyncFunctionBody_ )

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 *undefined*. The possible sources of completion values are Await or, if the async function doesn't await anything, step above. - 1. Return. + 1. Assert: _result_ is a normal completion with a value of ~unused~. The possible sources of completion values are Await or, if the async function doesn't await anything, step above. From f126c1697e98ba737f23d5e73b04d81e3532c5ae Mon Sep 17 00:00:00 2001 From: Kevin Gibbons Date: Thu, 29 Apr 2021 13:03:52 -0700 Subject: [PATCH 2/3] no argument-less return --- spec.html | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/spec.html b/spec.html index 676d3faf28..93b5e5bd1b 100644 --- a/spec.html +++ b/spec.html @@ -824,12 +824,7 @@

Implicit Completion Values

1. Assert: _completionRecord_ is a Completion Record. 1. Return _completionRecord_ as the Completion Record of this abstract operation. -

A “return” statement without a value in an algorithm step means the same thing as:

- - 1. Return NormalCompletion(~unused~). - -

In the above step, ~unused~ is a special value which is never directly consumed.

-

If all steps in an abstract operation have been executed without returning, the abstract operation behaves as though there were an additional step reading "Return." after the existing steps.

+

If all steps in an abstract operation have been executed without returning, the abstract operation behaves as though there were an additional step reading "Return NormalCompletion(~unused~)." after the existing steps. ~unused~ is a special value which is never directly consumed.

Any reference to a Completion Record value that is in a context that does not explicitly require a complete Completion Record value is equivalent to an explicit reference to the [[Value]] field of the Completion Record value unless the Completion Record is an abrupt completion.

@@ -3574,7 +3569,7 @@

Await

1. Perform ! PerformPromiseThen(_promise_, _onFulfilled_, _onRejected_). 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. Set the code evaluation state of _asyncContext_ such that when evaluation is resumed with a Completion _completion_, the following steps of the algorithm that invoked Await will be performed, with _completion_ available. - 1. Return. + 1. Return NormalCompletion(~unused~). 1. NOTE: This returns to the evaluation of the operation that had most previously resumed evaluation of _asyncContext_. @@ -39482,7 +39477,7 @@

AsyncFunctionStart ( _promiseCapability_, _asyncFunctionBody_ )

1. Else, 1. Assert: _result_.[[Type]] is ~throw~. 1. Perform ! Call(_promiseCapability_.[[Reject]], *undefined*, « _result_.[[Value]] »). - 1. [id="step-asyncfunctionstart-return-undefined"] Return. + 1. [id="step-asyncfunctionstart-return-undefined"] Return NormalCompletion(~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. From 3443b6b46c1c21b70bb3bf54df79741331ad0a84 Mon Sep 17 00:00:00 2001 From: Kevin Gibbons Date: Thu, 29 Apr 2021 20:28:12 -0700 Subject: [PATCH 3/3] partially address jmdyck's comments --- spec.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec.html b/spec.html index 93b5e5bd1b..ffc7aeab1a 100644 --- a/spec.html +++ b/spec.html @@ -824,7 +824,7 @@

Implicit Completion Values

1. Assert: _completionRecord_ is a Completion Record. 1. Return _completionRecord_ as the Completion Record of this abstract operation. -

If all steps in an abstract operation have been executed without returning, the abstract operation behaves as though there were an additional step reading "Return NormalCompletion(~unused~)." after the existing steps. ~unused~ is a special value which is never directly consumed.

+

If an abstract operation or syntax-directed operation completes execution without returning, it behaves as though there were an additional step reading "Return NormalCompletion(~unused~)." after the existing steps. ~unused~ is a special value which is never directly consumed. Operations that may return NormalCompletion(~unused~) are typically invoked in a "Perform" step.

Any reference to a Completion Record value that is in a context that does not explicitly require a complete Completion Record value is equivalent to an explicit reference to the [[Value]] field of the Completion Record value unless the Completion Record is an abrupt completion.