Laythe-lang / Laythe

A gradually typed language originally based on the crafting interpreters series
MIT License
65 stars 4 forks source link

Implement Minimal TypeChecker for basic class shape #137

Open jonnyboyC opened 1 year ago

jonnyboyC commented 1 year ago

Summary

Right now we don't have any type checking in Laythe. So far this has been fine but we have a synergy now with another problem. Specifically we don't have a good way for a user to subclass a "native" class. Today our native classes are built in the rust code but because of that our regular compiler code doesn't know which fields or method are available on the class. Today we use the ClassAttributes structs to track fields but these are only present in user provided code.

In order to solve this we could produce a minimal type checker that really only handles classes and primitives. Once we have this in place we can build a type for each native function, constant and class. In the user provided code we could then use this type signature to extend