-
Notifications
You must be signed in to change notification settings - Fork 38
Closed
Description
While we intend to maintain the consensus that an evaluated await using
will always imply an implicit Await
at the end of the block, it was suggested that the return value of a synchronous [Symbol.dispose]()
method shouldn't itself be Await
-ed, even if that method returns a Promise
so as to remain consistent with the synchronous using
statement.
The following is are examples of the current behavior and the suggested behavior:
Current behavior
{
using x = { [Symbol.dispose]() { return Promise.reject(new Error("x")); } };
} // return value ignored, does not throw on block exit
{
await using y = { [Symbol.dispose]() { return Promise.reject(new Error("y")); } };
} // implicit `await` for return value, throws Error("y") on block exit
Suggested behavior
{
using x = { [Symbol.dispose]() { return Promise.reject(new Error("x")); } };
} // return value ignored, does not throw on block exit
{
await using y = { [Symbol.dispose]() { return Promise.reject(new Error("y")); } };
} // implicit `await undefined`, return value ignored, does not throw on block exit
Metadata
Metadata
Assignees
Labels
No labels