Skip to content

Support array constant initialization for array of structs #1811

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

Merged
merged 4 commits into from
May 15, 2023

Conversation

ubaidsk
Copy link
Collaborator

@ubaidsk ubaidsk commented May 15, 2023

fixes #1789.

@ubaidsk ubaidsk requested a review from certik May 15, 2023 09:51
assert foos[1].y == 4

def main1() -> None:
foos2: Foo2[3] = array([])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The RHS is not correct, it's an array of length 0, assigning to array of length 3. So this should give either runtime or compile time error.


def main1() -> None:
foos2: Foo2[3] = array([])
foos2 = array([Foo2(-2.3, 42, u64(3)), Foo2(45.5, -3, u64(10001)), Foo2(1.0, -101, u64(100))])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just "merge" the previous two lines, then it should be ok.

@certik
Copy link
Contributor

certik commented May 15, 2023

Otherwise this looks good, thanks!

@ubaidsk ubaidsk requested a review from certik May 15, 2023 13:23
Copy link
Contributor

@certik certik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this looks great, thanks!

@certik certik merged commit 68024a0 into lcompilers:main May 15, 2023
@ubaidsk ubaidsk deleted the arr_of_struct branch May 18, 2023 07:17
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

Successfully merging this pull request may close these issues.

array of structures does not seem to work properly
2 participants