JSAbrahams / mamba

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

Modify our program within the type checker #165

Closed JSAbrahams closed 4 years ago

JSAbrahams commented 4 years ago

Relevant issues

163

Summary of the current issue

More advanced desugar rules are currently not implemented and would require duplicating much application logic in the desugar stage which is already present in the type checker.

Proposed change

The type checker has a deeper understanding of the structure of the application and depending on the structure of the application can easily modify it such that the desugar stage is trivial.

This would made possible by returning a new AST during each inference step.

JSAbrahams commented 4 years ago

We opted to have a pass before the inference (or in future generate constraint stage). The same application logic can also be used for another pass after this stage. The type checker is now as follows:

  1. build context
  2. modify AST based on context new
  3. infer types (in future generate constraints and annotate all nodes with types)