From ddd079557244d91947041fc207cf60cbe9c066cc Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Wed, 10 Apr 2024 14:07:18 -0400 Subject: [PATCH] Add PromiseCapability wrapper around sync dispose used in an `await using` (#218) --- spec.emu | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/spec.emu b/spec.emu index 0295215..d40261f 100644 --- a/spec.emu +++ b/spec.emu @@ -1068,9 +1068,12 @@ contributors: Ron Buckton, Ecma International 1. If _method_ is not *undefined*, then 1. Let _closure_ be a new Abstract Closure with no parameters that captures _method_ and performs the following steps when called: 1. Let _O_ be the *this* value. - 1. Perform ? Call(_method_, _O_). - 1. Return *undefined*. - 1. NOTE: This function is not observable to user code. It is used to ensure that a Promise returned from a synchronous `@@dispose` method will not be awaited. + 1. Let _promiseCapability_ be ! NewPromiseCapability(%Promise%). + 1. Let _result_ be Completion(Call(_method_, _O_)). + 1. IfAbruptRejectPromise(_result_, _promiseCapability_). + 1. Perform ? Call(_promiseCapability_.[[Resolve]], *undefined*, « *undefined* »). + 1. Return _promiseCapability_.[[Promise]]. + 1. NOTE: This function is not observable to user code. It is used to ensure that a Promise returned from a synchronous `@@dispose` method will not be awaited and that any exception thrown will not be thrown synchronously. 1. Return CreateBuiltinFunction(_closure_, 0, *""*, « »). 1. Else, 1. Let _method_ be ? GetMethod(_V_, @@dispose).