Skip to content

Switch with alternatives crashes #5402

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
nicolasstucki opened this issue Nov 7, 2018 · 2 comments
Closed

Switch with alternatives crashes #5402

nicolasstucki opened this issue Nov 7, 2018 · 2 comments

Comments

@nicolasstucki
Copy link
Contributor

val a: Int = 4
a match {
  case 1 => println("1")
  case 1 | 2 => println("1 or 2")
}

crashes with

duplicate keys in SWITCH, can't pick arbitrarily one of them to evict, see SI-6011.
java.lang.RuntimeException: duplicate keys in SWITCH, can't pick arbitrarily oneof them to evict, see SI-6011.
        at dotty.tools.backend.jvm.DottyBackendInterface.abort(DottyBackendInterface.scala:390)
        at scala.tools.nsc.backend.jvm.BCodeIdiomatic$JCodeMethodN.emitSWITCH(BCodeIdiomatic.scala:477)
        at scala.tools.nsc.backend.jvm.BCodeBodyBuilder$PlainBodyBuilder.genMatch(BCodeBodyBuilder.scala:909)
        at scala.tools.nsc.backend.jvm.BCodeBodyBuilder$PlainBodyBuilder.genLoad(BCodeBodyBuilder.scala:431)
@nicolasstucki nicolasstucki changed the title Switch with or cases crashes Switch with alternatives crashes Nov 7, 2018
@andrevidela
Copy link

@liufengyun I have a pull request incoming for this fix that I did during last weekend's Scala spree. Could I take care of this?

@smarter
Copy link
Member

smarter commented Dec 21, 2018

@andrevidela Yes no problem, I'll assign myself to this issue and I'll review your PR once it's open.

@smarter smarter self-assigned this Dec 21, 2018
nicolasstucki added a commit that referenced this issue Jan 4, 2019
Fix #5402: Avoid duplicate labels in switches
nicolasstucki pushed a commit to dotty-staging/dotty that referenced this issue Jan 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants