Explicit resource management proposal describes using as describing "a synchronously-disposed, block-scoped resource". The intent of using is that the resource is automatically disposed of at the end of the enclosing block, so block scoping makes sense.
Additionally, the proposal shows equivalent transpiled code as using a const binding.
Currently Oxc generates a binding with symbol flags FunctionScopedVariable, and hoists the binding to scope of enclosing function (like var). I believe it should behave like const - flags BlockScopedVariable | ConstVariable, and the binding should not be hoisted.
function f() {
{
using x = 123;
}
}
Playground
In the above example, the binding x should not be hoisted to top level of function f.
Explicit resource management proposal describes
usingas describing "a synchronously-disposed, block-scoped resource". The intent ofusingis that the resource is automatically disposed of at the end of the enclosing block, so block scoping makes sense.Additionally, the proposal shows equivalent transpiled code as using a
constbinding.Currently Oxc generates a binding with symbol flags
FunctionScopedVariable, and hoists the binding to scope of enclosing function (likevar). I believe it should behave likeconst- flagsBlockScopedVariable | ConstVariable, and the binding should not be hoisted.Playground
In the above example, the binding
xshould not be hoisted to top level of functionf.