Skip to content

Allow to append to a list inside a struct #2429

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

Open
Tracked by #2258
certik opened this issue Nov 18, 2023 · 0 comments
Open
Tracked by #2258

Allow to append to a list inside a struct #2429

certik opened this issue Nov 18, 2023 · 0 comments

Comments

@certik
Copy link
Contributor

certik commented Nov 18, 2023

Following up on #2428

This does not work:

asr: Transactions = Transactions(transactions=transactions, accounts=accounts)
s: Account = Account(name="OK")
asr.accounts.append(s)

with the error:

$ lpython --show-asr -I. process.py
semantic error: Only Name type and constant integers supported in Call
 --> process.py:7:1
  |
7 | asr.accounts.append(s)
  | ^^^^^^^^^^^^^^^^^^^^^^ 

But this workaround works:

accounts: list[Account] = []
asr: Transactions = Transactions(transactions=transactions, accounts=accounts)
s: Account = Account(name="OK")
accounts.append(s)
@certik certik mentioned this issue Nov 18, 2023
9 tasks
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