From a1234e95cb9e5cffaec43055df02fee63cbc7e31 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Wed, 21 Mar 2018 11:35:01 +0000 Subject: [PATCH] Editorial: refactor PerformPromiseThen to allow no capability Fixes #694. --- spec.html | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/spec.html b/spec.html index 93b3c1a5b13..086d152f396 100644 --- a/spec.html +++ b/spec.html @@ -3060,9 +3060,7 @@

Await

1. Let _stepsRejected_ be the algorithm steps defined in . 1. Let _onRejected_ be CreateBuiltinFunction(_stepsRejected_, « [[AsyncContext]] »). 1. Set _onRejected_.[[AsyncContext]] to _asyncContext_. - 1. Let _throwawayCapability_ be ! NewPromiseCapability(%Promise%). - 1. Set _throwawayCapability_.[[Promise]].[[PromiseIsHandled]] to *true*. - 1. Perform ! PerformPromiseThen(_promiseCapability_.[[Promise]], _onFulfilled_, _onRejected_, _throwawayCapability_). + 1. Perform ! PerformPromiseThen(_promiseCapability_.[[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. @@ -38204,7 +38202,7 @@

AsyncGeneratorRequest Records

[[Capability]] - A PromiseCapability record + A PromiseCapability record, or *undefined* The promise capabilities associated with this request. @@ -38293,9 +38291,7 @@

AsyncGeneratorResumeNext ( _generator_ )

1. Let _stepsRejected_ be the algorithm steps defined in . 1. Let _onRejected_ be CreateBuiltinFunction(_stepsRejected_, « [[Generator]] »). 1. Set _onRejected_.[[Generator]] to _generator_. - 1. Let _throwawayCapability_ be ! NewPromiseCapability(%Promise%). - 1. Set _throwawayCapability_.[[Promise]].[[PromiseIsHandled]] to *true*. - 1. Perform ! PerformPromiseThen(_promiseCapability_.[[Promise]], _onFulfilled_, _onRejected_, _throwawayCapability_). + 1. Perform ! PerformPromiseThen(_promiseCapability_.[[Promise]], _onFulfilled_, _onRejected_). 1. Return *undefined*. 1. Else, 1. Assert: _completion_.[[Type]] is ~throw~. @@ -38739,6 +38735,9 @@

PromiseReactionJob ( _reaction_, _argument_ )

1. Assert: _type_ is `"Reject"`. 1. Let _handlerResult_ be ThrowCompletion(_argument_). 1. Else, let _handlerResult_ be Call(_handler_, *undefined*, « _argument_ »). + 1. If _promiseCapability_ is *undefined*, then + 1. Assert: _handlerResult_ is not an abrupt completion. + 1. Return NormalCompletion(~empty~); 1. If _handlerResult_ is an abrupt completion, then 1. Let _status_ be Call(_promiseCapability_.[[Reject]], *undefined*, « _handlerResult_.[[Value]] »). 1. Else, @@ -39095,11 +39094,14 @@

Promise.prototype.then ( _onFulfilled_, _onRejected_ )

-

PerformPromiseThen ( _promise_, _onFulfilled_, _onRejected_, _resultCapability_ )

+

PerformPromiseThen ( _promise_, _onFulfilled_, _onRejected_ [ , _resultCapability_ ] )

The abstract operation PerformPromiseThen performs the “then” operation on _promise_ using _onFulfilled_ and _onRejected_ as its settlement actions. The result is _resultCapability_'s promise.

1. Assert: IsPromise(_promise_) is *true*. - 1. Assert: _resultCapability_ is a PromiseCapability Record. + 1. If _resultCapability_ is present, then + 1. Assert: _resultCapability_ is a PromiseCapability Record. + 1. Else, + 1. Set _resultCapability to *undefined*. 1. If IsCallable(_onFulfilled_) is *false*, then 1. Set _onFulfilled_ to *undefined*. 1. If IsCallable(_onRejected_) is *false*, then