tc39 / proposal-array-from-async

Draft specification for a proposed Array.fromAsync method in JavaScript.
http://tc39.es/proposal-array-from-async/
BSD 3-Clause "New" or "Revised" License
177 stars 13 forks source link

Spec Tidy Suggestion: Don't Double Construct A #35

Closed mgaudet closed 1 year ago

mgaudet commented 1 year ago

As written, the spec -may- double counstruct A:

It will be constructed first as part of Step 3.{e,f}; then if iteratorRecord is undefined, it's constructed again in Step 3.k.{iv,v}.

Probably that first construction could be sunk into 3.j.

ptomato commented 1 year ago

I found this as well, while writing test262 tests. Here's a code snippet showing how it's observable from JS:

class MyArray {
  constructor(...args) {
    console.log('called with', args);
  }
}
await Array.fromAsync.call(MyArray, {
  length: 2,
  0: 1,
  1: 2
});

This logs:

called with 
called with 2
michaelficarra commented 1 year ago

I've opened #41 to fix this and added it to the May agenda for approval by committee.

js-choi commented 1 year ago

My apologies for being absent from the discussion. This is a great catch, and #41 looks good to me. @michaelficarra: I’ll get in touch on Element regarding next week’s plenary presentation.