Skip to content

[explicit-resource-management] Add remaining tests specific to await using statement syntax #4481

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

rbuckton
Copy link
Contributor

In an effort to make review more manageable, this extracts the remaining tests specific to await using statement syntax from #3866

@rbuckton rbuckton requested a review from a team as a code owner May 12, 2025 15:44
Copy link
Contributor

@ptomato ptomato left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I learned a lot reviewing this PR. Thanks!

Comment on lines 13 to 17
asyncTest(async function () {
await assert.throwsAsync(TypeError, async function() {
for (await using i = 0; i < 1; i++) {}
});
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Early errors do not forbid this. await using i = 0 is allowed in the ForInitializer of a for statement. The error raised is due to the assignment in i++ which attempts to modify an immutable binding.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, got it. I noticed you changed this to expect a ReferenceError instead of a TypeError, though. Are you sure that is correct? I get a TypeError from modifying another immutable binding such as for (const x of [1, 2, 3]) { x++ }.

/*---
esid: pending
description: >
await using: invalid assignment in Statement body
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It'd be good to note in the info that the error is thrown in CreateDisposableResource

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error raised is due to the assignment in x++ which attempts to modify an immutable binding.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same question about ReferenceError.

@rbuckton rbuckton force-pushed the explicit-resource-management-await-using-syntax branch from 1c7f1de to bd747be Compare June 2, 2025 17:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants