- About Scala
- Documentation
- Code Examples
- Software
- Scala Developers
"x$1 not found"
Mon, 2009-07-06, 22:40
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?