Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Editorial: add a ReturnCompletion AO, mirroring NormalCompletion/ThrowCompletion #3415

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"license": "SEE LICENSE IN https://tc39.es/ecma262/#sec-copyright-and-software-license",
"homepage": "https://tc39.es/ecma262/",
"devDependencies": {
"ecmarkup": "^19.0.0",
"ecmarkup": "^19.1.0",
"glob": "^7.1.6",
"jsdom": "^15.0.0",
"pagedjs": "^0.4.3",
Expand Down
41 changes: 27 additions & 14 deletions spec.html
Original file line number Diff line number Diff line change
Expand Up @@ -1028,7 +1028,7 @@ <h1>ReturnIfAbrupt Shorthands</h1>
<h1>Implicit Normal Completion</h1>
<p>In algorithms within abstract operations which are declared to return a Completion Record, and within all built-in functions, the returned value is first passed to NormalCompletion, and the result is used instead. This rule does not apply within the Completion algorithm or when the value being returned is clearly marked as a Completion Record in that step; these cases are:</p>
<ul>
<li>when the result of applying Completion, NormalCompletion, or ThrowCompletion is directly returned</li>
<li>when the result of applying Completion, NormalCompletion, ThrowCompletion, or ReturnCompletion is directly returned</li>
<li>when the result of constructing a Completion Record is directly returned</li>
</ul>
<p>It is an editorial error if a Completion Record is returned from such an abstract operation through any other means. For example, within these abstract operations,</p>
Expand Down Expand Up @@ -4181,6 +4181,19 @@ <h1>
</emu-alg>
</emu-clause>

<emu-clause id="sec-returncompletion" type="abstract operation">
<h1>
ReturnCompletion (
_value_: an ECMAScript language value,
michaelficarra marked this conversation as resolved.
Show resolved Hide resolved
): a return completion
</h1>
<dl class="header">
</dl>
<emu-alg>
1. Return Completion Record { [[Type]]: ~return~, [[Value]]: _value_, [[Target]]: ~empty~ }.
</emu-alg>
</emu-clause>

<emu-clause id="sec-updateempty" type="abstract operation">
<h1>
UpdateEmpty (
Expand Down Expand Up @@ -13423,7 +13436,7 @@ <h1>
1. Else,
1. Let _rhs_ be ? Evaluation of |AssignmentExpression|.
1. Let _value_ be ? GetValue(_rhs_).
1. Return Completion Record { [[Type]]: ~return~, [[Value]]: _value_, [[Target]]: ~empty~ }.
1. Return ReturnCompletion(_value_).
</emu-alg>
<emu-note>
<p>Even though field initializers constitute a function boundary, calling FunctionDeclarationInstantiation does not have any observable effect and so is omitted.</p>
Expand Down Expand Up @@ -22572,14 +22585,14 @@ <h2>Syntax</h2>
<h1>Runtime Semantics: Evaluation</h1>
<emu-grammar>ReturnStatement : `return` `;`</emu-grammar>
<emu-alg>
1. Return Completion Record { [[Type]]: ~return~, [[Value]]: *undefined*, [[Target]]: ~empty~ }.
1. Return ReturnCompletion(*undefined*).
</emu-alg>
<emu-grammar>ReturnStatement : `return` Expression `;`</emu-grammar>
<emu-alg>
1. Let _exprRef_ be ? Evaluation of |Expression|.
1. Let _exprValue_ be ? GetValue(_exprRef_).
1. If GetGeneratorKind() is ~async~, set _exprValue_ to ? Await(_exprValue_).
1. Return Completion Record { [[Type]]: ~return~, [[Value]]: _exprValue_, [[Target]]: ~empty~ }.
1. Return ReturnCompletion(_exprValue_).
</emu-alg>
</emu-clause>
</emu-clause>
Expand Down Expand Up @@ -23681,7 +23694,7 @@ <h1>Runtime Semantics: Evaluation</h1>
<emu-alg>
1. Let _exprRef_ be ? Evaluation of |AssignmentExpression|.
1. Let _exprValue_ be ? GetValue(_exprRef_).
1. Return Completion Record { [[Type]]: ~return~, [[Value]]: _exprValue_, [[Target]]: ~empty~ }.
1. Return ReturnCompletion(_exprValue_).
</emu-alg>
</emu-clause>
</emu-clause>
Expand Down Expand Up @@ -24006,7 +24019,7 @@ <h1>
1. Set _G_.[[GeneratorBrand]] to ~empty~.
1. Set _G_.[[GeneratorState]] to ~suspended-start~.
1. Perform GeneratorStart(_G_, |FunctionBody|).
1. Return Completion Record { [[Type]]: ~return~, [[Value]]: _G_, [[Target]]: ~empty~ }.
1. Return ReturnCompletion(_G_).
</emu-alg>
</emu-clause>

Expand Down Expand Up @@ -24146,14 +24159,14 @@ <h1>Runtime Semantics: Evaluation</h1>
1. Set _value_ to _received_.[[Value]].
1. If _generatorKind_ is ~async~, then
1. Set _value_ to ? Await(_value_).
1. Return Completion Record { [[Type]]: ~return~, [[Value]]: _value_, [[Target]]: ~empty~ }.
1. Return ReturnCompletion(_value_).
1. Let _innerReturnResult_ be ? Call(_return_, _iterator_, « _received_.[[Value]] »).
1. If _generatorKind_ is ~async~, set _innerReturnResult_ to ? Await(_innerReturnResult_).
1. If _innerReturnResult_ is not an Object, throw a *TypeError* exception.
1. Let _done_ be ? IteratorComplete(_innerReturnResult_).
1. If _done_ is *true*, then
1. Set _value_ to ? IteratorValue(_innerReturnResult_).
1. Return Completion Record { [[Type]]: ~return~, [[Value]]: _value_, [[Target]]: ~empty~ }.
1. Return ReturnCompletion(_value_).
1. If _generatorKind_ is ~async~, set _received_ to Completion(AsyncGeneratorYield(? IteratorValue(_innerReturnResult_))).
1. Else, set _received_ to Completion(GeneratorYield(_innerReturnResult_)).
</emu-alg>
Expand Down Expand Up @@ -24234,7 +24247,7 @@ <h1>
1. Set _generator_.[[GeneratorBrand]] to ~empty~.
1. Set _generator_.[[AsyncGeneratorState]] to ~suspended-start~.
1. Perform AsyncGeneratorStart(_generator_, |FunctionBody|).
1. Return Completion Record { [[Type]]: ~return~, [[Value]]: _generator_, [[Target]]: ~empty~ }.
1. Return ReturnCompletion(_generator_).
</emu-alg>
</emu-clause>

Expand Down Expand Up @@ -25250,7 +25263,7 @@ <h1>
1. Perform ! Call(_promiseCapability_.[[Reject]], *undefined*, « _completion_.[[Value]] »).
1. Else,
1. Perform AsyncFunctionStart(_promiseCapability_, |FunctionBody|).
1. Return Completion Record { [[Type]]: ~return~, [[Value]]: _promiseCapability_.[[Promise]], [[Target]]: ~empty~ }.
1. Return ReturnCompletion(_promiseCapability_.[[Promise]]).
</emu-alg>
</emu-clause>

Expand Down Expand Up @@ -25357,7 +25370,7 @@ <h1>
1. Perform ! Call(_promiseCapability_.[[Reject]], *undefined*, « _completion_.[[Value]] »).
1. Else,
1. Perform AsyncFunctionStart(_promiseCapability_, |ExpressionBody|).
1. Return Completion Record { [[Type]]: ~return~, [[Value]]: _promiseCapability_.[[Promise]], [[Target]]: ~empty~ }.
1. Return ReturnCompletion(_promiseCapability_.[[Promise]]).
</emu-alg>
</emu-clause>

Expand Down Expand Up @@ -48028,7 +48041,7 @@ <h1>%GeneratorPrototype%.return ( _value_ )</h1>
<p>This method performs the following steps when called:</p>
<emu-alg>
1. Let _g_ be the *this* value.
1. Let _C_ be Completion Record { [[Type]]: ~return~, [[Value]]: _value_, [[Target]]: ~empty~ }.
1. Let _C_ be ReturnCompletion(_value_).
1. Return ? GeneratorResumeAbrupt(_g_, _C_, ~empty~).
</emu-alg>
</emu-clause>
Expand Down Expand Up @@ -48357,7 +48370,7 @@ <h1>%AsyncGeneratorPrototype%.return ( _value_ )</h1>
1. Let _promiseCapability_ be ! NewPromiseCapability(%Promise%).
1. Let _result_ be Completion(AsyncGeneratorValidate(_generator_, ~empty~)).
1. IfAbruptRejectPromise(_result_, _promiseCapability_).
1. Let _completion_ be Completion Record { [[Type]]: ~return~, [[Value]]: _value_, [[Target]]: ~empty~ }.
1. Let _completion_ be ReturnCompletion(_value_).
1. Perform AsyncGeneratorEnqueue(_generator_, _completion_, _promiseCapability_).
1. Let _state_ be _generator_.[[AsyncGeneratorState]].
1. If _state_ is either ~suspended-start~ or ~completed~, then
Expand Down Expand Up @@ -48608,7 +48621,7 @@ <h1>
1. Let _awaited_ be Completion(Await(_resumptionValue_.[[Value]])).
1. If _awaited_ is a throw completion, return ? _awaited_.
1. Assert: _awaited_ is a normal completion.
1. Return Completion Record { [[Type]]: ~return~, [[Value]]: _awaited_.[[Value]], [[Target]]: ~empty~ }.
1. Return ReturnCompletion(_awaited_.[[Value]]).
</emu-alg>
</emu-clause>

Expand Down
Loading