Skip to content

Add structs using dataclasses #607

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

Closed
4 tasks done
certik opened this issue Jun 15, 2022 · 1 comment
Closed
4 tasks done

Add structs using dataclasses #607

certik opened this issue Jun 15, 2022 · 1 comment

Comments

@certik
Copy link
Contributor

certik commented Jun 15, 2022

We need to support structs using the following syntax:

@dataclass
class A:
    x: i32
    y: f32

def f(a: A):
    print(a.x)
    print(a.y)

def g():
    x: A = A()
    x.x = 5
    x.y = 5.5
    f(x)

g()

I think this already works at the ASR level and in LLVM, so the tasks are:

  • Implement support for this at the AST->ASR level
  • LLVM tests
  • CPython tests
  • C tests
@certik
Copy link
Contributor Author

certik commented Jul 19, 2022

The basic features now work and are tested in CPython, LLVM and C.

@certik certik closed this as completed Jul 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant