Closed Bug 1170742 Opened 10 years ago Closed 10 years ago

Update Promise.resolve to match latest spec (no [[PromiseConstructor]])

Categories

(Core :: DOM: Core & HTML, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: cscott, Unassigned)

References

Details

TC39 agreed to get rid of the hidden [[PromiseConstructor]] property from the spec and simplify `Promise.resolve`. The adopted proposal also makes Promise.resolve ignore "species": https://esdiscuss.org/topic/fixing-promise-resolve Opening an issue to track adoption of the new semantics. Steps to reproduce: Execute this in the console: p = Promise.resolve(5); p.constructor = {} p2 = Promise.resolve(p) p===p2 Actual results: "true" Expected results: According to latest spec, p===p2 should be "false".
We don't really implement the old semantics, for what it's worth. I'm guessing that we'll update some of this stuff as we implement Promise subclassing, though.
Depends on: 1170760
For what it's worth, you can implement the proper semantics now -- Promise.resolve() no longer depends on the details of subclassing, it uses a simple test of the "constructor" property. As you can tell by the test case above, Firefox *does* currently implement the "hidden [[PromiseConstructor]] field" semantics of the old spec, which were errata'ed out of existence. So it's worth changing in the near term to prevent this wrong behavior from spreading.
Sure. If the promise subclassing stuff doesn't turn out to be near-term (like a month or so), we can fix this up separately. But I suspect it'll be near-term.
Fixed in bug 1170760.
Status: UNCONFIRMED → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.