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 unions T1 | T2 | T3 ... Tn #496

Open
2 of 5 tasks
Luna-Klatzer opened this issue Jul 27, 2023 · 1 comment
Open
2 of 5 tasks

[Feature] Implement type unions T1 | T2 | T3 ... Tn #496

Luna-Klatzer opened this issue Jul 27, 2023 · 1 comment
Labels
feature New feature or enhancement
Milestone

Comments

@Luna-Klatzer
Copy link
Member

Luna-Klatzer commented Jul 27, 2023

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 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:

def func(value: num | str) -> num {
  // Convert the value if it is of type 'str'
  if (typeof(value) == str) {
    value = value as str;
  }
  return value * 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.
  • Implement proper type translation to TypeScript.

Related issues

@Luna-Klatzer Luna-Klatzer added the feature New feature or enhancement label Jul 27, 2023
@Luna-Klatzer Luna-Klatzer added this to the v0.11.0 milestone Jul 27, 2023
@Luna-Klatzer Luna-Klatzer self-assigned this Jul 27, 2023
@Luna-Klatzer Luna-Klatzer changed the title [Feature] Implement support for custom inline union types [Feature] Implement support for custom inline type unions Jul 27, 2023
@Luna-Klatzer Luna-Klatzer removed their assignment Jul 3, 2024
@Luna-Klatzer Luna-Klatzer modified the milestones: v0.11.0, v0.12.0 Jul 9, 2024
@Luna-Klatzer Luna-Klatzer removed this from the v0.12.0 milestone Jul 18, 2024
@Luna-Klatzer Luna-Klatzer moved this from Todo to Under Consideration in Kipper Language Development Jul 18, 2024
@Luna-Klatzer
Copy link
Member Author

Internal unions and base logic implemented by #680.

@Luna-Klatzer Luna-Klatzer mentioned this issue Jul 24, 2024
21 tasks
@Luna-Klatzer Luna-Klatzer mentioned this issue Sep 18, 2024
39 tasks
@Luna-Klatzer Luna-Klatzer changed the title [Feature] Implement support for custom inline type unions [Feature] Implement type unions T1 | T2 | T3 ... Tn Sep 25, 2024
@Luna-Klatzer Luna-Klatzer moved this from Under Consideration to Todo in Kipper Language Development Sep 25, 2024
@Luna-Klatzer Luna-Klatzer added this to the v0.13.0 milestone Sep 25, 2024
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

No branches or pull requests

1 participant