Skip to content

Shouldn't await using early throw for non-disposable objects? #208

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

Closed
PaperStrike opened this issue Oct 28, 2023 · 2 comments · Fixed by #217 or #219
Closed

Shouldn't await using early throw for non-disposable objects? #208

PaperStrike opened this issue Oct 28, 2023 · 2 comments · Fixed by #217 or #219
Labels
normative Indicates a normative change to the specification

Comments

@PaperStrike
Copy link

In #180, the [Symbol.dispose] method is wrapped when hint is 'async-dispose', even if the method is undefined. This bypasses the outer check in CreateDisposableResource, where it would typically trigger a TypeError for undefined method. I find this behavior unexpected, as the original issue #179 did not intend to alter the behavior of await using / AsyncDisposableStack.use in a way that it would no longer throw errors for non-disposable values before usage but only when disposing.

@PaperStrike PaperStrike changed the title Should await using early throw for non-disposable objects? Shouldn't await using early throw for non-disposable objects? Nov 10, 2023
@rbuckton
Copy link
Collaborator

It is not necessary to throw here, GetMethod does that for us.

@rbuckton
Copy link
Collaborator

I misspoke, you are correct that GetMethod will return undefined when the function is null or undefined, which is not the intent of that change. Thank you for pointing out the discrepancy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment