Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: Scala 2.10.0
    • Component/s: Misc Compiler
    • Labels:
      None

      Description

      Paste the following in the REPL (r22631):

      import scala.xml._
      def updateNodes(ns: Seq[Node]): Seq[Node] =
        for(subnode <- ns) yield subnode match {
          case <d>{_}</d> if true => <d>abc</d>
          case Elem(prefix, label, attribs, scope, children @ _*) =>
            Elem(prefix, label, attribs, scope, updateNodes(children) : _*)
          case other => other
        }
      updateNodes(<b />)
      

      The result is:

      java.lang.VerifyError: (class: $$anonfun$$updateNodes$$1, method: apply
          signature: (Lscala/xml/Node;)Lscala/xml/Node;) Accessing value from
          uninitialized register 17
              at .updateNodes(<console>:46)
              at .<init>(<console>:46)
              at .<clinit>(<console>)
              at RequestResult$$.<init>(<console>:9)
      

      Notably, if the "if true" is removed, the generated classfile is ok. Also, the same code works under 2.7.7, so it's a regression.

        Activity

        Hide
        James Matlik added a comment -

        This issue can be reproduced without a conditional on the match. The following seems to exhibit the same symptoms.

        import scala.xml._
        def test(node: Node){
          def p(ns: Seq[Node]){
            for(subnode <- ns) subnode match {
              case Elem(prefix, label, attribs, scope, Text(text)) => println("has single text child")
              case Elem(prefix, label, attribs, scope, child @ _*) => { println("has children"); p(child)}
            }
          }
          p(node.theSeq)
        }
        test(<a>b</a>)
        

        It would appear that three criteria needed to be met in this case:

        • A more specific pattern comes first
        • The more general pattern uses the `child @ _*` notation
        • The more general pattern uses recursion.
        Show
        James Matlik added a comment - This issue can be reproduced without a conditional on the match. The following seems to exhibit the same symptoms. import scala.xml._ def test(node: Node){ def p(ns: Seq[Node]){ for(subnode <- ns) subnode match { case Elem(prefix, label, attribs, scope, Text(text)) => println("has single text child") case Elem(prefix, label, attribs, scope, child @ _*) => { println("has children"); p(child)} } } p(node.theSeq) } test(<a>b</a>) It would appear that three criteria needed to be met in this case: A more specific pattern comes first The more general pattern uses the `child @ _*` notation The more general pattern uses recursion.
        Hide
        daniele.bettella added a comment -

        bug confirmed in scala versions 2.8.0 final and 2.9.0.1

        Show
        daniele.bettella added a comment - bug confirmed in scala versions 2.8.0 final and 2.9.0.1
        Hide
        Paul Phillips added a comment -

        virtpatmat saves day, test in 8bc8b83f0b .

        Show
        Paul Phillips added a comment - virtpatmat saves day, test in 8bc8b83f0b .

          People

          • Assignee:
            Adriaan Moors
            Reporter:
            Antonio Cunei
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development