Skip to content

Allow to append to a list inside a struct #2429

Open
@certik

Description

@certik

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions