-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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
Await nullish async disposable #16408
Conversation
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/56669 |
@@ -39,6 +39,8 @@ export default function _usingCtx() { | |||
throw new TypeError(`Property [Symbol.dispose] is not a function.`); | |||
} | |||
stack.push({ v: value, d: dispose, a: isAwait }); | |||
} else if (isAwait) { | |||
stack.push({ a: isAwait }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you explicitly set d
to undefined
, given that we read it later?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or set it to false to save a few bytes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could probably use value
here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Anything works for me as long as it's something :)
6ef1fe9
to
6600aec
Compare
@@ -39,6 +39,9 @@ export default function _usingCtx() { | |||
throw new TypeError(`Property [Symbol.dispose] is not a function.`); | |||
} | |||
stack.push({ v: value, d: dispose, a: isAwait }); | |||
} else if (isAwait) { | |||
// provide the nullish `value` as `d` for minification gain | |||
stack.push({ d: value, a: isAwait }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aside: currently await using x = document.all
will go to this branch, we probably should reject it. I will check the spec and open a new PR to fix that.
There will be some changes related to this in the proposal: tc39/proposal-explicit-resource-management#219 We will have a conclusion at the end of the week. |
In the REPL example,
It should log
"f body", "body", "y"
, but currently it logs"f body", "y", "body"
.Per spec 7.5.7 Dispose, if
hint
isasync-dispose
, the result should be awaited, even if it is nullish. Therefore the disposing of the next resourcey
should followlog.push("body")
.