Skip to content

lambda + PartialFunction + specialization = "VerifyError: Bad local variable type" #11817

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

Open
SethTisue opened this issue Dec 2, 2019 · 1 comment
Assignees
Labels
erasure fixed in Scala 3 This issue does not exist in the Scala 3 compiler (https://github.com/lampepfl/dotty/) minimized runtime crash
Milestone

Comments

@SethTisue
Copy link
Member

this came up over at #7288, the original report there got fixed but this version remains broken even in 2.13.1

object SI_7288 {
  type Id[A] = A
  def f[A](pf: PartialFunction[A, Unit]): Unit = ()
  f[Id[Int]] { case _ => }
  def main(args: Array[String]): Unit = ()
}

Exception in thread "main" java.lang.VerifyError: Bad local variable type
Exception Details:
  Location:
    Main$$anonfun$1.applyOrElse(ILscala/Function1;)Ljava/lang/Object; @0: aload_1
  Reason:
    Type integer (current frame, locals[1]) is not assignable to reference type
@hrhino
Copy link

hrhino commented Dec 6, 2019

That's because it's actually not the same... This can be minimized to

type Id[A] = A
def fail[A <: Id[Int]](a: A) = a

where the erased type of a is mistakenly computed to be Object, while the erased type of fail is computed to be (I)I.

@SethTisue SethTisue added the fixed in Scala 3 This issue does not exist in the Scala 3 compiler (https://github.com/lampepfl/dotty/) label Jan 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
erasure fixed in Scala 3 This issue does not exist in the Scala 3 compiler (https://github.com/lampepfl/dotty/) minimized runtime crash
Projects
None yet
3 participants