Aladdin - Scala Bugtracking
[#646] project: compiler priority: medium category: bug
submitter assigned to status date submitted
Burak Burak fixed 2006-06-29 11:19:16.0
subject typing of patterns, cont'd
code
object xfor {

  import scala.xml.NodeSeq

    val books = 
    <bks>
      <title>Blabla</title>
      <title>Blubabla</title>
      <title>Baaaaaaalabla</title>
    </bks>;

  new NodeSeq { val theSeq = books.child } match {
    case t @ <title>Blabla</title> => t
  }

}
what happened
[emir@lamppc31 scala.fallback.trunk]$ build/quick/bin/scalac -d /tmp /tmp/xfor.scala
Exception in thread "main" java.lang.NullPointerException
        at scala.tools.nsc.typechecker.Typers$Typer.typedIdent$0(Typers.scala:1275)
        at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:1671)
        at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:1731)
        at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:1761)
...
what expected
[back to overview]
Changes of this bug report
Burak  edited on  2006-06-29 11:28:42.0
Here's an even simpler one
object xfor {

  List(<a/>) match {
    case t @ <a>Blabla</a> => t
  }
}
which is of course equivalent (simplified the pattern a bit) to
object xfor {
  List(<a/>) match {
    case t @ Seq(scala.xml.Elem(_,"a",_,_,_*)) => t
  }
}
Martin  edited on  2006-07-11 16:15:57.0
I guess it was fixed by some previous change. It compiles OK now.
Burak  edited on  2006-10-12 12:37:59.0
reopen! I guess the "fix" was due to my worsening the type by parsing it to Seq(Elem(...)) instead of Elem(...). This is unnecessary. Now that I made the parse use the better (more precise) pattern Elem (which is <: Node <: NodeSeq <: Seq), I would not expect this error message.
Note that the code below compiles fine -- should the refinement really matter for patterns? If yes, you could change the status from "bug" to "feature".
  val n: NodeSeq = new NodeSeq { val theSeq = books.child } 
  n match {
    case t @ Blabla => t
  }
Martin  edited on  2006-10-26 16:52:05.0
I get:
bug646.scala:13 error: constructor cannot be instantiated to expected type;
 found   : scala.xml.Elem
 required: scala.xml.NodeSeq{def theSeq: scala.xml.Node*}
    case t @ Blabla => t
               ^
one error found
Not sure whether that's correct or not. I reassigned to Burak.
Burak  edited on  2007-03-03 03:01:16.0