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
Implement support for union types, which allow declarations to have more complex types and be used in more complex situations.
The syntax for unions would be:
T1|T2|T3| ... |Tn
Where n would be any desired value i.e. there is no compiler-enforced limit of the maximum amount of unioned types.
For example:
deffunc(value: num|str)->num{// Convert the value if it is of type 'str'if(typeof(value)==str){value=valueasstr;}returnvalue*value;}
Exact behaviour / changes you want
Implement union-type syntax allowing multiple types for any declaration.
Implement internal compiler support for type unions, so they are properly handled in all cases i.e. enforced to be narrowed down to a single type if a specific use case requires it.
Luna-Klatzer
changed the title
[Feature] Implement support for custom inline union types
[Feature] Implement support for custom inline type unions
Jul 27, 2023
Is there an existing proposal for this?
This feature does not exist in the latest version
Proposal
Implement support for union types, which allow declarations to have more complex types and be used in more complex situations.
The syntax for unions would be:
Where
n
would be any desired value i.e. there is no compiler-enforced limit of the maximum amount of unioned types.For example:
Exact behaviour / changes you want
Related issues
typeof
#369str
,num
,bool
etc. #495The text was updated successfully, but these errors were encountered: