JSAbrahams / mamba

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

Checker cannot deal with type alias #329

Open JSAbrahams opened 2 years ago

JSAbrahams commented 2 years ago

Description of Bug

Checker cannot deal with type alias.

How to Reproduce

when checking

type MyType: String

def a: MyType := "my_string"
print(a)

We get Unifying two types: Expected a 'MyType', was a 'String'

Expected behavior

If something is an alias, then we should check for the alias type and not the type itself.

JSAbrahams commented 2 years ago

Within the current language, it actually makes sense that this does not pass. As it is writting, MyType is a child of String, which should make the checker fail. If we had def a: String = MyType(...), then it would pass, because the left side is the parent of the right side.