Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] Implement type conversion for primitive types #133

Closed
2 tasks done
Tracked by #146 ...
Luna-Klatzer opened this issue May 24, 2022 · 2 comments · Fixed by #146
Closed
2 tasks done
Tracked by #146 ...

[Feature] Implement type conversion for primitive types #133

Luna-Klatzer opened this issue May 24, 2022 · 2 comments · Fixed by #146
Assignees
Labels
feature New feature or enhancement
Milestone

Comments

@Luna-Klatzer
Copy link
Member

Luna-Klatzer commented May 24, 2022

Is there an existing proposal for this?

  • I have searched the existing issues

This feature does not exist in the latest version

  • I am using the latest version

Proposal

Implement type conversion that allows for expressions to be converted into other types using the following syntax:

exp as type

Exact behaviour you want

  • Implement support for the syntax and allow for proper semantic analysis, where the expression and type are evaluated properly.
  • Implement type checking to verify that the conversion is valid. Only the following basic conversions should be supported at first:
    • num as str - Return the literal number in string format.
    • str as num - Return the parsed number from the string, if it contains invalid characters, it will return NaN.
    • bool as str - In case of true return "true" otherwise "false".
    • bool as num - In case of true return 1 and otherwise 0.
    • any as bool - In case that the value is not 0, "", or false return true.
  • Implement TypeScript translation for the type conversion expression.
@Luna-Klatzer Luna-Klatzer added the feature New feature or enhancement label May 24, 2022
@Luna-Klatzer Luna-Klatzer self-assigned this May 24, 2022
@Luna-Klatzer Luna-Klatzer changed the title [Feature] Implement type conversion [Feature] Implement basic type conversion May 24, 2022
@Luna-Klatzer Luna-Klatzer added this to the Stable Kipper Release milestone May 24, 2022
@Luna-Klatzer Luna-Klatzer changed the title [Feature] Implement basic type conversion [Feature] Implement type conversion for primitive types Jun 3, 2022
@Luna-Klatzer
Copy link
Member Author

The implementation of any as bool will be delayed until any types are implemented.

@Luna-Klatzer Luna-Klatzer linked a pull request Jun 3, 2022 that will close this issue
2 tasks
@Luna-Klatzer
Copy link
Member Author

Implemented by #146

This was referenced Jun 3, 2022
@Luna-Klatzer Luna-Klatzer added this to the v0.8.0 milestone Jan 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or enhancement
Projects
Development

Successfully merging a pull request may close this issue.

1 participant