Problems with using Union types
- Dominant language
- Python
- Stars
- 16.8k
- Forks
- 603
- Avg merge
- 4d 23h
- Merged PRs (30d)
- 6
Description
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)`
Contributor guide
Assessment
This issue has not been assessed yet.