Aladdin - Scala Bugtracking
[#872] project: compiler priority: medium category: missing feature
submitter assigned to status date submitted
Burak Martin won't fix 2006-12-24 23:00:32.0
subject stable, mutable patterns?
code
object Foo {
  var Bar = 23
  42 match {
    case Bar => 
  }
}
what happened
/tmp/xmasbug.scala:4 error: stable identifier required, but Foo.this.Bar found.
    case Bar => 
         ^
one error found
what expected allow all stable patterns (esp. named constant patterns referencing class members) to be mutable
[back to overview]
Changes of this bug report
Martin  edited on  2007-01-06 15:56:00.0
Martin  edited on  2007-01-06 15:56:25.0
That would be a spec change. I am not sure we should do this, though.
Burak  edited on  2007-01-08 11:36:27.0
Here are the relevant parts of the spec (so I change this to feature request, although I leave status at 'won't fix')

§8 ... A named pattern constant r is a stable identifier (§3.1). To resolve the syntactic over- lap with a variable pattern, a named pattern constant may not be a simple name starting with a lower-case letter. The type of r must conform to the expected type of the pattern. The pattern matches any value v such that r == v (§12.1).

§3.1 A stable identifier is a path that ends in an identifier and the text further restricts paths such that

• p .x where p is a path and x is a stable member of p . Stable members are members introduced by value or object definitions, as well as packages.