Skip to content

Problems with using Union types #766

@variux

Description

@variux

Hi

To give a general idea I'm working on a wrapper for sqlite3 in codon, a function takes a parameter that can takes multiple types

Ex: str, int, bool

But this little code breaks

`Param = Union[str, int, bool]
value: Param = "test"

print(type(value))`

$ codon run test.py union.codon:27 (44-45): error: __ptr__() only takes identifiers or tuple fields as arguments ├─ union.codon:92 (28-64): error: during the realization of _get_data(u: TypeWrap[Union[bool | int | str]], T: bool) ├─ str.codon:27 (20-36): error: during the realization of _str(union: TypeWrap[Union[bool | int | str]]) ├─ builtin.codon:28 (27-33): error: during the realization of __new__(what: TypeWrap[Union[bool | int | str]]) ╰─ test.py:4 (1-6): error: during the realization of print(*args: Tuple[TypeWrap[Union[bool | int | str]]], sep: str, end: str, file: Ptr[byte], flush: bool)

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