Certain fields are undefined when accessing children of classes.
How to Reproduce
type.mamba:
class MyGeneric: String
class MyType(def some_field: String)
type SomeState: MyClass when self.private_field > 2
type OtherState: MyClass when
self.private_field > 10
self.private_field < 200
self.required_field < 50
type SuperInterface
def bar: Int
type MyInterface: SuperInterface
def required_field: Int
def higher_order(self) -> int
# some class
class MyClass(def my_field: Int, other_field: String := "Hello"): MyType(other_field), MyInterface
def required_field: Int := 100
def private_field: Int := 20
def fun_a(self: SomeState) => self.some_field := "my field is {self.required_field}"
def fun_b(self) => print("this function is private: {self.private_field}!")
def some_higher_order(self, fun: Int -> Int) -> Int => return fun(self.my_field)
def higher_order(self) -> Int => return self.some_higher_order(\x: Int => x * 2)
Gives the following errors:
Error: Cannot infer type within call property. Expected a `self`.private_field, was Int
โโโ types.mamba:4:30
4 | type SomeState: MyClass when self.private_field > 2
^^^^^^^^^^^^^^^^^^
We expect an Int, but MyInterface does not define private_field
โโโ types.mamba:4:30
4 | type SomeState: MyClass when self.private_field > 2
^^^^^^^^^^^^^^^^^^
โโโ In call property
4 | type SomeState: MyClass when self.private_field > 2
^^^^^^^
We expect a String, but MyInterface does not define some_field
โโโ types.mamba:22:35
22 | def fun_a(self: SomeState) => self.some_field := "my field is {self.required_field}"
^^^^^^^^^^^^^^^
โโโ In call property
22 | def fun_a(self: SomeState) => self.some_field := "my field is {self.required_field}"
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Cause
I expect that this is because the Context is not being properly created.
Was noted in #416
However, because this is most likely an issue with the Context, will not solve there but created an issue.
Perhaps because the check stage now works more properly we run into issues here.
Description of Bug
Certain fields are undefined when accessing children of classes.
How to Reproduce
type.mamba
:Gives the following errors:
Cause
I expect that this is because the
Context
is not being properly created. Was noted in #416 However, because this is most likely an issue with theContext
, will not solve there but created an issue. Perhaps because the check stage now works more properly we run into issues here.