title: Stable identifier required during pattern matching? (Scala)
body: <p>Trying to produce a list of tuples showing prime factor multiplicity... the idea is to match each integer in a sorted list against the first value in a tuple, using the second value to count. Could probably do it more easily with <code>takeWhile</code>, but meh. Unfortunately my solution won't compile:</p>
  
  <pre><code>  def primeFactorMultiplicity (primeFactors: List[Int]) = {
  
      primeFactors.foldRight (List[(Int, Int)]()) ((a, b) =&gt; (a, b) match {
        case (_, Nil)       =&gt; (a, 1) :: b
        case (b.head._1, _) =&gt; (a, b.head._2 + 1) :: b.tail
        case _              =&gt; (a, 1) :: b
      })
    }
  </code></pre>
  
  <p>It says "error: stable identifier required, but b.head._1 found." But changing the second <code>case</code> line to the following works fine:</p>
  
  <pre><code>      case (i, _) if (i == b.head._1) =&gt; (a, b.head._2 + 1) :: b.tail
  </code></pre>
  
  <p>Why is this, and why can't the compiler cope if there is such a simple fix?</p>