You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
$ 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)
This seems to be an issue with printing the union type itself, since the first two lines do work. You can also use e.g. isinstance(param, str) to check for a particular type.
By the way, you can do this fully at compile-time via a pattern like:
Activity
arshajii commentedon Mar 4, 2026
This seems to be an issue with printing the union type itself, since the first two lines do work. You can also use e.g.
isinstance(param, str)to check for a particular type.By the way, you can do this fully at compile-time via a pattern like:
If you don't give
paraman explicit union type, then Codon can deduce the type at compile-time and only compile the appropriateif/elifbranch.variux commentedon Mar 4, 2026
I wanted to print the type to say
Type {type} is not supportedbut even being able to print it, it doesn't print the actual typeyfinkelstein commentedon Mar 7, 2026
Related: #738