-
-
Notifications
You must be signed in to change notification settings - Fork 35
Add support for cast(X, Y} #585
Copy link
Copy link
Closed
Labels
enhancementNew feature or requestNew feature or request
Description
I have seen many implementations awkwardly use typed assignments (a: X = Y) to implement type casts. Python does have a canonical way of doing type casts within expressions, cast. OpShin should support this.
The way this should be implemented is allowing the import of cast from typing in the typing import rewriter, and giving it a special polymorphic function type (basically return type = first argument). the function should check comparability of types, i.e. that X <= actual type or actual type <= X, similar to how typed assignments are handled in the aggressive type inferencer.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request