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
VerifyError: unsorted lookupswitch #6011
Comments
Imported From: https://issues.scala-lang.org/browse/SI-6011?orig=1 |
@paulp said: This is more than sufficient: object Test {
def f(ch: Char): Any = ch match {
case 'b' | 'B' => 1
case 'c' | 'C' => 2
case 'd' | 'u' | 'i' | 'o' | 'x' | 'X' | 'c' => 3
case 'f' | 'e' | 'E' | 'g' | 'G' => 4
case 'h' | 'H' => 5
case 's' => 6
case _ => 7
}
def main(args: Array[String]): Unit = {
f('a')
}
} |
@paulp said: object Test {
def f(ch: Char): Any = ch match {
case 'a' | 'b' => 1
case 'z' | 'a' => 1
}
def main(args: Array[String]): Unit = f('a')
} |
@magarciaEPFL said:
The list of int pair The problem above is the duplicate The backend can silently swallow duplicate |
@paulp said: |
@magarciaEPFL said: |
@dragos said: object Test {
var cond = false
def f(ch: Char): Any = ch match {
case 'a' if cond => 1
case 'z' | 'a' => 2
}
def main(args: Array[String]): Unit = f('a')
} |
@adriaanm said: Technically, it depends on the granularity of the reachable entities you're considering. I'm trying to figure out how to consider reachability per alternative, but that's tricky to describe in general. What if you have several nested alternatives (inside other patterns) in one case? |
@dragos said: For the record, you could fall back to if-then-elses if there are duplicate entries with different guards (like the old one did). |
@adriaanm said: Yes, we shouldn't emit switches like this, and fall back. |
@paulp said:
What deters you from expanding all the alternatives up front? This was something the old matcher did which I thought was approximately correct: copy patterns around until alternatives are gone. |
@adriaanm said: |
@adriaanm said: |
The following macro throws a VerifyError when run. Variations on the error are possible. There need to be enough cases to cause a lookupswitch to be generated.
The text was updated successfully, but these errors were encountered: