tc39 / proposal-explicit-resource-management

ECMAScript Explicit Resource Management
https://arai-a.github.io/ecma262-compare/?pr=3000
BSD 3-Clause "New" or "Revised" License
758 stars 30 forks source link

Can an `ExpressionStatement` start with `using [` ? #223

Closed lgalfaso closed 6 months ago

lgalfaso commented 6 months ago

If this proposal were to be accepted, can an ExpressionStatement start with using [?

Eg, how should the code below be interpreted?

function foo() {
  return {};
}

const a = 1;
var using = [];
{
  using [a] = foo();
}

There is currently nothing in the proposal that adds a restriction on ExpressionStatement to prevent an ExpressionStatement to start with using [. This implies that the line using [a] = foo(); can be interpreted as an ExpressionStatement and as a UsingDeclaration.

lgalfaso commented 6 months ago

I just notice that there is a new parameter Pattern in BindingList that would prevent this from being interpreted as a UsingDeclaration. Sorry for the noise.