-
Notifications
You must be signed in to change notification settings - Fork 167
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Class TODO list #2680
Comments
Hey @tanay-man, you can start with a very simple code and try to compile that using LPython. class Test():
i = 5
x = Test()
print(x.i) $ python test.py
5 This needs to be statically typed to be compiled by LPython, So, we can do from lpython import i32
class Test():
i: i32 = 5
x: Test = Test()
print(x.i) $ python test.py
5 Make sure that every LPython code must also be compiled using CPython. $ lpython test.py
semantic error: Only dataclass-decorated classes and Enum subclasses are supported.
--> test.py:12:1 - 13:11
|
12 | class Test():
| ^^^^^^^^^^^^^...
...
|
13 | i: i32 = 5
| ...^^^^^^^^^^^
Note: Please report unclear or confusing messages as bugs at
https://github.com/lcompilers/lpython/issues. Try to analyse the AST and then start handling this in the ASR (Sematics phase) |
The above code is working. The |
@tanay-man, now we have some initial implementation. You can start testing by adding some more tests, also port some tests from lfortran, like class_03, Inheritance, ... |
lfortran integration_tests/class_01.f90 --show-asr
to learn how ASR works for classes (see what is supported inclass_*.f90
The text was updated successfully, but these errors were encountered: