From 689a396b84891cf61795545b104882b3a59ded08 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 | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/spec.html b/spec.html index fcac57f9721..c0868d37916 100644 --- a/spec.html +++ b/spec.html @@ -2988,9 +2988,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. @@ -37180,9 +37178,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~. @@ -37391,7 +37387,7 @@

PromiseReaction Records

[[Capability]] - A PromiseCapability Record + A PromiseCapability Record, or *undefined* The capabilities of the promise for which this record provides a reaction handler. @@ -37610,6 +37606,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, @@ -37963,11 +37962,14 @@

Promise.prototype.then ( _onFulfilled_, _onRejected_ )

This function is the %PromiseProto_then% intrinsic object.

-

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.

+

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

+The abstract operation PerformPromiseThen performs the “then” operation on _promise_ using _onFulfilled_ and _onRejected_ as its settlement actions. If _resultCapability_ is passed, the result is stored by updating _resultCapability_’s promise. (If it is not passed, then PerformPromiseThen is being called by a specification-internal operation where the result does not matter.)

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