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

Stack overflow during specialization #7184

Closed
scabug opened this issue Feb 25, 2013 · 2 comments
Closed

Stack overflow during specialization #7184

scabug opened this issue Feb 25, 2013 · 2 comments
Assignees
Milestone

Comments

@scabug
Copy link

scabug commented Feb 25, 2013

This example:

import scala.{ specialized => spec }

object Test {
  def blowup[@spec(Int) A](arr: Array[A]): Array[A] = {
    arr.length match {
      case 0 => arr
      case _ => arr
    }
  }
}

leads to the following:

[info] Compiling 1 Scala source to /home/adam/code/SpecBug/target/scala-2.10/classes...
[error] 
[error]      while compiling: /home/adam/code/SpecBug/src/main/scala/Test2.scala
[error]         during phase: specialize
[error]      library version: version 2.10.0
[error]     compiler version: version 2.10.0
[error]   reconstructed args: -deprecation -bootclasspath /usr/lib/jvm/java-7-oracle/jre/lib/resources.jar:/usr/lib/jvm/java-7-oracle/jre/lib/rt.jar:/usr/lib/jvm/java-7-oracle/jre/lib/sunrsasign.jar:/usr/lib/jvm/java-7-oracle/jre/lib/jsse.jar:/usr/lib/jvm/java-7-oracle/jre/lib/jce.jar:/usr/lib/jvm/java-7-oracle/jre/lib/charsets.jar:/usr/lib/jvm/java-7-oracle/jre/lib/jfr.jar:/usr/lib/jvm/java-7-oracle/jre/classes:/home/adam/.sbt/0.12.2/boot/scala-2.10.0/lib/scala-library.jar -unchecked -d /home/adam/code/SpecBug/target/scala-2.10/classes -classpath /home/adam/code/SpecBug/target/scala-2.10/classes:/home/adam/.ivy2/cache/org.scala-lang/scala-reflect/jars/scala-reflect-2.10.0.jar
[error] 
[error]   last tree to typer: Ident(arr)
[error]               symbol: value arr (flags: <param> <triedcooking>)
[error]    symbol definition: arr: Array[A]
[error]                  tpe: Array[A]
[error]        symbol owners: value arr -> method blowup -> object Test -> package <empty>
[error]       context owners: value x1 -> method blowup$mIc$sp -> object Test -> package <empty>
[error] 
[error] == Enclosing template or block ==
[error] 
[error] Block(
[error]   ValDef( // case val x1: Int
[error]     case <synthetic> <triedcooking>
[error]     "x1"
[error]     <tpt> // tree.tpe=Int
[error]     Apply( // def length(): Int in class Array, tree.tpe=Int
[error]       "arr"."length" // def length(): Int in class Array, tree.tpe=()Int
[error]       Nil
[error]     )
[error]   )
[error]   Match( // tree.tpe=Array[A]
[error]     "x1" // case val x1: Int
[error]     // 2 cases
[error]     CaseDef( // tree.tpe=Array[A]
[error]       1
[error]       "arr" // arr: Array[Int], tree.tpe=Array[A]
[error]     )
[error]     CaseDef( // tree.tpe=Array[A]
[error]       "_" // tree.tpe=Int
[error]       "arr" // arr: Array[Int], tree.tpe=Array[A]
[error]     )
[error]   )
[error] )
[error] 
[error] == Expanded type of tree ==
[error] 
[error] TypeRef(
[error]   TypeSymbol(
[error]     final class Array[T] extends Serializable with Cloneable
[error]   )
[error]   args = List(SkolemTypeRef(TypeSkolem(A)))
[error] )
[error] 
[error] uncaught exception during compilation: java.lang.StackOverflowError
[trace] Stack trace suppressed: run last compile:compile for the full output.
[error] (compile:compile) java.lang.StackOverflowError
[error] Total time: 1 s, completed Feb 25, 2013 6:41:01 PM

Doesn't cause problems in 2.9.2

@scabug
Copy link
Author

scabug commented Feb 25, 2013

Imported From: https://issues.scala-lang.org/browse/SI-7184?orig=1
Reporter: Adam Klein (aklein-at-novus.com)
Affected Versions: 2.10.0

@scabug
Copy link
Author

scabug commented Feb 26, 2013

@retronym said:
Duplicate of #7100.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants