JSAbrahams / mamba

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

Unification stage often fails when unifing accesses #228

Closed JSAbrahams closed 2 years ago

JSAbrahams commented 2 years ago

Description of Bug

Unification stage appears to fail when performing access:

class A
    def (a, b): (Int, Int) := (10, 100)

def a := A()
print a.a
print a.b

Gives the following error:

[error | type] Cannot infer type. Expected a String, was `a.a`.__str__(`a.a`)
  6 | print a.a
            ^^^

This happens also with primitives: I.e.:

[error | type] Cannot infer type. Expected a String, was `self.required_field@0`.__str__(`self.required_field@0`)
  22 |     def fun_a(self: SomeState) => self.some_field := "my field is {self.required_field}"
                                                                          ^^^^^^^^^^^^^^^^^^^
  23 |     def fun_b(self) => print "this function is private: {self.private_field}!"

More in-depth description might follow.