Skip to content

Enum members and union types #2711

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

Closed
felixmulder opened this issue Jun 8, 2017 · 5 comments
Closed

Enum members and union types #2711

felixmulder opened this issue Jun 8, 2017 · 5 comments

Comments

@felixmulder
Copy link
Contributor

enum ParseResult {
  case Trees(xs: List[Int])
  case Errors(xs: List[String])
  case Incomplete
  case Exit
}

import ParseResult._

type Fine     = Trees | Errors
type NotFine0 = Trees | Incomplete
type NotFine1 = Trees | Errors | Incomplete
type NotFine2 = Trees | Errors | Exit

I'm assuming this is due to Incomplete and Exit getting desugared into:

final case val Exit: Test.ParseResult = Test.ParseResult.$new(3, "Exit")

ping @odersky

felixmulder added a commit to dotty-staging/dotty that referenced this issue Jun 8, 2017
@sjrd
Copy link
Member

sjrd commented Jun 8, 2017

What's wrong? You should write

type Fine     = Trees | Errors
type NotFine0 = Trees | Incomplete.type
type NotFine1 = Trees | Errors | Incomplete.type
type NotFine2 = Trees | Errors | Exit.type

@felixmulder
Copy link
Contributor Author

@sjrd - singleton types are not allowed in union types currently

@japgolly
Copy link
Contributor

japgolly commented Jun 8, 2017

singleton types are not allowed in union types currently

oh god... please tell me that's going to change at some point.

@felixmulder
Copy link
Contributor Author

@japgolly - there was some breakage a while back, where at the time, we decided that fixing the breakage was more important than allowing singleton types in unions.

I'm hoping that we can get back to enabling this again, but so far other things have taken priority. If you're interested in helping out on this, we're more than happy to help you get started :)

felixmulder added a commit to dotty-staging/dotty that referenced this issue Jun 15, 2017
felixmulder added a commit to dotty-staging/dotty that referenced this issue Aug 2, 2017
felixmulder added a commit to dotty-staging/dotty that referenced this issue Aug 11, 2017
felixmulder added a commit to dotty-staging/dotty that referenced this issue Aug 11, 2017
felixmulder added a commit to dotty-staging/dotty that referenced this issue Aug 17, 2017
felixmulder added a commit to dotty-staging/dotty that referenced this issue Aug 22, 2017
felixmulder added a commit to dotty-staging/dotty that referenced this issue Aug 22, 2017
felixmulder added a commit to dotty-staging/dotty that referenced this issue Aug 23, 2017
@smarter
Copy link
Member

smarter commented Jan 26, 2019

This appears to be a special case of #1551 so closing this one in favor of the other.

@smarter smarter closed this as completed Jan 26, 2019
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

No branches or pull requests

4 participants