JSAbrahams / mamba

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

Desugar default constructors to init functions #105

Closed JSAbrahams closed 5 years ago

JSAbrahams commented 5 years ago

Current Issue

Default constructors are ignored.

Description of the feature

Default constructors are constructors stored alongside the class name, i.e.:

class MyServer(mut self: DisconnectedMyServer, def ip_address: IPv4Address) isa Server

The above should be desugared such that we have an init function where these are assigned to self. So the above is roughly desugared to (self should be ignored):

class MyServer(Server):
    ip_address = None

    __init__(self, ip_address):
        self.ip_address = ip_address

Description of potential solution

We desugar class nodes such that:

The type checker should that that there is no other init function in the class.