Skip to content

DataClass: Empty list initialization unsupported #1723

Open
@ubaidsk

Description

@ubaidsk

Example:

(lp) lpython$ cat examples/expr2.py    
from lpython import i32, dataclass

@dataclass
class A:
    x: list[i32]

def main0():
    a: A = A([])

main0()
(lp) lpython$ python examples/expr2.py
(lp) lpython$ lpython examples/expr2.py
semantic error: Type mismatch in procedure call; the types must be compatible
 --> examples/expr2.py:8:14
  |
8 |     a: A = A([])
  |              ^^ type mismatch (passed argument type is list[A] but required type is list[i32])
  |
5 |     x: list[i32]
  |     ^^^^^^^^^^^^ type mismatch (passed argument type is list[A] but required type is list[i32])


Note: if any of the above error or warning messages are not clear or are lacking
context please report it to us (we consider that a bug that must be fixed).

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