kevinbarabash / compiler

2 stars 0 forks source link

Make some progress on function subtyping #8

Closed kevinbarabash closed 2 years ago

kevinbarabash commented 2 years ago

This allows passing a callback with fewer params than is expected. This is to support things like array.map((x) => x) since the full callback accepts three params, e.g. array.map((x, index, array) => x).

The is a bug with the current implementation which is that we allow array.map((x, y, z, w) => x) which is undecidable by the type system since we also support partial application and we don't know how many args map applies to the callback.

One foo function is a subtype of another bar if:

This PR doesn't allow subtype relations between the params or return types of foo and bar so there's more work to do.