josefs / Gradualizer

A Gradual type system for Erlang
MIT License
613 stars 35 forks source link

Define subtyping of unions with type difference #566

Open erszcz opened 5 months ago

erszcz commented 5 months ago

This borrows the idea of defining the subtyping relation from set-theoretic types, but we only use it for subtyping of unions. This issue was made clearly visible in @xxdavid's #564 and we spoke about it face to face on Lambda Days earlier this week.

However, there are some basic tests which stopped passing, like test/should_pass/guard.erl or lookup/2 in poly_should_pass.erl, so it needs more investigation. The main troublemaker, different_normalization_levels.erl, works now, though.

xxdavid commented 5 months ago

Impressive, thanks for trying it out! It breaks when any() is used, for example any() | not_found <: float() | not_found and false | true <: integer() | any() do not hold any more, but this can probably be tweaked somehow.