Add type inference for argument and return types
Bug #575731 reported by
Matt Giuca
This bug affects 1 person
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Mars |
Triaged
|
Wishlist
|
Matt Giuca |
Bug Description
A lot of recent work has gone into inferring variable types so variables no longer require declaration (bug #483082). We can now go a step further and not require explicit argument and return type annotations (Mars will be a fully type-inferred language).
Due to the way we have set up the type checker, this should actually be very easy -- it should only require changes to the parser. Any argument/return which leaves off a type should be bound to an *unnamed* type variable. The fact that it is unnamed means it will not be made rigid, and thus may become bound. That should be sufficient to get type inference working.
To post a comment you must log in.
In parsem, algorithmically generate a unique name for each unnamed type variable, from the set {"a", "b", "c", ...}. Otherwise, you will start seeing functions with types like t_1 -> t_2.
It is important to do this *after* the set of rigid variables is generated (it is based on which variables are named, and we don't want these variables to become rigid just because they have a name).