flofriday / Moose

🐐 A new fun programming language
MIT License
6 stars 1 forks source link

Typechecking for Inheritance does not work for >2 super classes #11

Closed Jozott00 closed 2 years ago

Jozott00 commented 2 years ago

So for example

class A < B { a: String }
class B < C { }
class C { a: Int }

does not crash. This is because we flat() all classes in the ClassStatement typechecker. Since we call flat() on A before we typechecked B (and therefore determine its superclass), we could not see a: Int in B, and therefore cannot check the type.

I guess we need a third pass, that runs through and flats all classes after each class has its superclass typechecked.

flofriday commented 2 years ago

Could we before we flat() them check if they have intersecting values?

Jozott00 commented 2 years ago

Nope, since we have to flat the superclass before we can check against intersecting values... flat() is a recursive function which calls flat() on the superclass before checking for other stuff.