paulmillr / es6-shim

ECMAScript 6 compatibility shims for legacy JS engines
http://paulmillr.com
MIT License
3.11k stars 387 forks source link

Update behavior of `Promise.resolve`. #344

Closed cscott closed 9 years ago

cscott commented 9 years ago

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 es6-shim adopting the new semantics.

ljharb commented 9 years ago

It'd be ideal to also check on #239 as part of this work.

cscott commented 9 years ago

Working on it right now (both this and #239, plus some incidental fixes to iterators).

ljharb commented 9 years ago

@cscott there's another issue - see the tests in https://github.com/ljharb/es6-shim/commit/c29937b1e7da5a905e55369e97853cb3ef8a5c4c . It looks like our implementation (along with v8, Firefox, and JSC, whereas Bluebird passes) all fail these tests which are part of the spec. Mind taking a look at these too? :-)

cscott commented 9 years ago

Those tests don't look right to me at all. Can you point me at the upstream source for them?

cscott commented 9 years ago

In particular, the Promise Resolve function should execute the then in a PromiseResolveThenableJob, which means it should not be synchronous. Am I misreading the spec?

ljharb commented 9 years ago

You're correct - my initial commit was wrong, if you look at the latest one (comment has been updated) it tests that ".then" is called only once, as well as that the ".then" property is retrieved synchronously (es6-shim currently retrieves it asynchronously).

ljharb commented 9 years ago

Fixed with 9542dda06c1812cefd14b5c6101a9f35ec1f2eda / #345