JSAbrahams / mamba

🐍 The Mamba programming language, because we care about safety
MIT License
85 stars 3 forks source link

Type checker should annotate the AST with types #279

Closed JSAbrahams closed 2 years ago

JSAbrahams commented 2 years ago

Current Issue

The type checker does not annotate the AST with types. This makes more "advanced" language features, such as automatically returning the last expression (without return), or treating a match as an expression more difficult.

A few issues which would benefit:

This also saves a lot of types which we can use to annotate our Python output. Throwing this away is a shame.

JSAbrahams commented 2 years ago

In the unification stage, we have the position of the asts. One option is to return a set of positions and types at that position. Then, for each position, we can recursively go through the AST and as soon as the position is found we annotate that ASTTy with the type.

JSAbrahams commented 2 years ago

I doubt this feature will really help with #278 , but still nice to have of course.