Add type inference for argument and return types

Bug #575731 reported by Matt Giuca
6
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.

Tags: types
Revision history for this message
Matt Giuca (mgiuca) wrote :

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).

Revision history for this message
Matt Giuca (mgiuca) wrote :

Or just fix the type printer to generate nice names for unnamed type variables (a, b, c, ... instead of t_1, t_2, t_3, ...), making sure that no generated name collides with a named variable.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.