JSAbrahams / mamba

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

Cannot get name of generics in declaration #443

Open JSAbrahams opened 1 year ago

JSAbrahams commented 1 year ago

Description of Bug

Currently, no mechanism yet to get generics of declarations.

How to Reproduce

A small example:

class MyClass[T]
    def f(x: T) -> T => x

def x := MyClass[Int]()

Gives an error when trying to process the following in check stage:

def x := MyClass[Int]()

During the generate stage, it correctly identifies this as a function call. However, the function name is a StringName, and this causes a problem because we call (pseudocode ahead) StringName::try_from(MyClass[Int]). Because StringName does not know how to deal with Node:Index (which is how it is parsed).

Expected behavior

Should be converted to a StringName. This should be a quick fix in TryFrom<&AST> for StringName.

Once implemented, then the internal generic logic of check stage which we implemented recently (in part to get collections to work) should take over.