-
Notifications
You must be signed in to change notification settings - Fork 494
[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
base: main
Are you sure you want to change the base?
[explicit-resource-management] Add remaining tests specific to await using
statement syntax
#4481
Conversation
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.
I learned a lot reviewing this PR. Thanks!
test/language/statements/await-using/syntax/await-using-allowed-at-top-level-of-module.js
Outdated
Show resolved
Hide resolved
...t-using/syntax/block-scope-syntax-await-using-declarations-mixed-with-without-initializer.js
Show resolved
Hide resolved
asyncTest(async function () { | ||
await assert.throwsAsync(TypeError, async function() { | ||
for (await using i = 0; i < 1; i++) {} | ||
}); | ||
}); |
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.
Should this not result in a SyntaxError, due to https://tc39.es/ecma262/#sec-let-and-const-declarations-static-semantics-early-errors?
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.
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.
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.
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 |
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.
It'd be good to note in the info
that the error is thrown in CreateDisposableResource
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.
The error raised is due to the assignment in x++
which attempts to modify an immutable binding.
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.
Same question about ReferenceError.
1c7f1de
to
bd747be
Compare
In an effort to make review more manageable, this extracts the remaining tests specific to
await using
statement syntax from #3866