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

Add a rule to determine which extension types are always-exhaustive #3568

Merged
merged 2 commits into from
Jan 17, 2024

Conversation

eernstg
Copy link
Member

@eernstg eernstg commented Jan 17, 2024

See #3524 (comment) for background information.

This PR adds a rule to the extension type feature specification, specifying that an extension type is always-exhaustive if and only if its instantiated representation type is always-exhaustive (note that this rule may be applied repeatedly because the representation type could itself be an extension type).

Example:

extension type SmartBool(bool b) {}

String foo(SmartBool sb) {
  switch (sb) { // This switch must be exhaustive.
    case SmartBool(b: true): return 'True';
    case SmartBool(b: false): return 'False';
  }
}

It is my understanding that this behavior has already been implemented (perhaps it was implemented like that all the time), so there should not be any implementation effort associated with this spec change.

We have (or will have) language tests about this as well, so it should be detected if it is not true that this behavior is implemented already.

@eernstg
Copy link
Member Author

eernstg commented Jan 17, 2024

@sgrekhov, I think we already acted on this change when the underlying language design question was decided? The actual text in the feature specification should not be controversial, and it should not change anything, but it would be great if you can double check the situation when this lands.

@sgrekhov
Copy link
Contributor

I'll check it

@eernstg eernstg merged commit 6579f38 into main Jan 17, 2024
3 checks passed
@eernstg eernstg deleted the spec_exttype_always_exhaustive_jan24 branch January 17, 2024 14:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants