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

"x$1 not found"

No replies
extempore
Joined: 2008-12-17,
User offline. Last seen 35 weeks 3 days ago.

Here is a little code snippet:

val List(isInt, isChar, isBoolean, isArray, isNothing) = {
import definitions._
def testFor(s: Symbol): Type => Boolean = (tpe: Type) => tpe.typeSymbol eq s

List(IntClass, CharClass, BooleanClass, ArrayClass, NothingClass) map testFor
}

This works fine in the repl:

scala> :power
** Power User mode enabled - BEEP BOOP **

scala> import interpreter.compiler._
import interpreter.compiler._

[paste code above]
isInt: (interpreter.compiler.Type) => Boolean =
isChar: (interpreter.compiler.Type) => Boolean =
isBoolean: (interpreter.compiler.Type) => Boolean =
isArray: (interpreter.compiler.Type) => Boolean =
isNothing: (interpreter.compiler.Type) => Boolean =

However in ParallelMatching it won't compile:

[scalacfork] /scala/trunk/src/compiler/scala/tools/nsc/matching/ParallelMatching.scala:80: error: not found: value x$1
[scalacfork] val List(isInt, isChar, isBoolean, isArray, isNothing) = {
[scalacfork] ^
[scalacfork] /scala/trunk/src/compiler/scala/tools/nsc/matching/ParallelMatching.scala:80: error: not found: value x$1
[scalacfork] val List(isInt, isChar, isBoolean, isArray, isNothing) = {
[scalacfork] ^
[scalacfork] /scala/trunk/src/compiler/scala/tools/nsc/matching/ParallelMatching.scala:80: error: not found: value x$1
[scalacfork] val List(isInt, isChar, isBoolean, isArray, isNothing) = {
[scalacfork] ^
[scalacfork] /scala/trunk/src/compiler/scala/tools/nsc/matching/ParallelMatching.scala:80: error: not found: value x$1
[scalacfork] val List(isInt, isChar, isBoolean, isArray, isNothing) = {
[scalacfork] ^
[scalacfork] /scala/trunk/src/compiler/scala/tools/nsc/matching/ParallelMatching.scala:80: error: not found: value x$1
[scalacfork] val List(isInt, isChar, isBoolean, isArray, isNothing) = {
[scalacfork] ^

The "x$1" should be the name of the temporary tuple created for the
pattern match. Why can't it see it?

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