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
725 stars 29 forks source link

Incorrect usage of InitializeReferencedBinding AO in ForIn/OfBodyEvaluation #172

Closed rbuckton closed 3 months ago

rbuckton commented 1 year ago

Steps 4-6 of ForIn/OfBodyEvaluation define the hint variable, which is intended to be passed to the InitializeReferencedBinding AO on steps 9.h.vii.5-6. This is necessary to correctly initialize a resource that uses Symbol.asyncDispose in the following statement:

for (await using x of y) {
}

The steps 9.h.vii.5-6 are currently

  1. If IsUsingDeclaration of lhs is true, then
    1. Let status be Completion(InitializeReferencedBinding(lhsRef, nextValue, sync-dispose)).
  2. Else,
    1. Let status be Completion(InitializeReferencedBinding(lhsRef, nextValue, normal)).

but should be

  1. Let status be Completion(InitializeReferencedBinding(lhsRef, nextValue, hint)).