You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@JohnSmith20211124 The issue you're encountering is due to a circular dependency between classes A and B. In Python, when you define a class attribute that depends on another class that hasn't been defined yet, you'll encounter a NameError because Python doesn't know about B when it's encountered in the definition of class A, and vice versa. You can use forward declarations to tell Python that a class exists without defining its attributes until later in the code. Another way to handle this is to use string names for the classes and then resolve the actual class objects later. Neither of these approaches works in Codon.
classA:
b: 'B'classB:
a: A
i482.py:2:8-11: error: expected type expression
As the error message explains, you need to define a type expression, not a string.
classA:
b: BclassB:
a: A
i482.py:2:8-9: error: name 'B' is not defined
That's because the Codon global scope is parsed from top to bottom.
The following code does not compile:
Error Message:
Even if you omit the quotes around the B it does not work.
The text was updated successfully, but these errors were encountered: