aantron / promise

Light and type-safe binding to JS promises
MIT License
341 stars 24 forks source link

Make native reason-promise covariant, like JS #49

Open aantron opened 4 years ago

aantron commented 4 years ago

c9d8008 marked JS promises covariant. We should do the same in the native version. However, that is a full implementation, and a correct implementation of promises usually prevents the compiler from admitting covariance (the compiler infers invariance). This is because such an implementation requires several helper data structures to defer callbacks and avoid memory leaks, so we need to either:

The current data structures don't (or shouldn't!!) make the promises invariant, the compiler just can't tell that they don't.

After dealing with this, the covariance tests should be made to run (rather, build) on both JS and native:

https://github.com/aantron/promise/blob/c9d8008ce37307748f619bd51487b6912c7ebc8b/test/js/test_ffi.re#L316-L360