This page is no longer maintained — Please continue to the home page at www.scala-lang.org

Type mismatch with no type mismatch?

1 reply
cristian.vrabie
Joined: 2011-12-20,
User offline. Last seen 42 years 45 weeks ago.

Anyone else happened to stumble on a type mismatch in which de "found"
and "required" types are the same? I'm building with SBT 10.1 / Scala
2.9.1 but Maven yields the same result. I didn't even know that could
happen, though I am very new to Scala :)

[error] /Users/cvrabie1/Work/viper/server/src/main/scala/com/viper/
ViperReports.scala:233: type mismatch;
[error] found :
(List[net.liftweb.common.Box[com.o2.viper.model.DriverScore]],
scala.xml.NodeSeq) => scala.xml.NodeSeq
[error] required:
(List[net.liftweb.common.Box[com.o2.viper.model.DriverScore]],
scala.xml.NodeSeq) => scala.xml.NodeSeq
[error] reportsMenu(titleOverallScore, "reports" :: "scores" ::
"overall" :: Nil, snippetReports(titleOverallScore,
oneValBindFunction(extractorOverall)), Empty),

Som Snytt
Joined: 2011-09-19,
User offline. Last seen 42 years 45 weeks ago.
Re: Type mismatch with no type mismatch?
CCing the list in case this helps anyone else, for the record.

>It can happen when a Tuple2 is required for the function argument, but you've passed two args instead.  Both print as (a,b).

I remembered emailing this to a friend who doesn't see why he should learn Scala yet.  This is not an example of why Scala is worth blowing one's mind, but is more in the vein of, it's all great fun.
----

This compiler error message is worth a chuckle.  It's claiming a type mismatch, but found and required look exactly the same (which was why I was confused in the first place).

[info] Compiling 1 Scala source to M:\apm\workspaces\indigo-jee\scala-experiments\target\scala-2.9.1\classes...
[error] M:\apm\workspaces\indigo-jee\scala-experiments\src\telecoder\Coder.scala:34: type mismatch;
[error]  found   : (Char, java.lang.String) => Boolean
[error]  required: (Char, java.lang.String) => Boolean
[error]   def lookUp(c: Char): Char = (dial find ((a:Char,b:java.lang.String) => b contains c)).get._1




On Tue, Dec 20, 2011 at 7:51 AM, cristian.vrabie <cristian.vrabie@gmail.com> wrote:
Anyone else happened to stumble on a type mismatch in which de "found"
and "required" types are the same? I'm building with SBT 10.1 / Scala
2.9.1 but Maven yields the same result. I didn't even know that could
happen, though I am very new to Scala :)

[error] /Users/cvrabie1/Work/viper/server/src/main/scala/com/viper/
ViperReports.scala:233: type mismatch;
[error]  found   :
(List[net.liftweb.common.Box[com.o2.viper.model.DriverScore]],
scala.xml.NodeSeq) => scala.xml.NodeSeq
[error]  required:
(List[net.liftweb.common.Box[com.o2.viper.model.DriverScore]],
scala.xml.NodeSeq) => scala.xml.NodeSeq
[error]     reportsMenu(titleOverallScore, "reports" :: "scores" ::
"overall" :: Nil, snippetReports(titleOverallScore,
oneValBindFunction(extractorOverall)), Empty),

Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland