summary refs log tree commit diff
path: root/src/test/compile-fail/assign-to-method.rs
blob: aea25979d9b2b91de042f2c4a065b24d42d59876 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// error-pattern:assigning to immutable field
class cat {
  priv {
    let mut meows : uint;
  }

  let how_hungry : int;

  fn speak() { meows += 1u; }
  new(in_x : uint, in_y : int) { meows = in_x; how_hungry = in_y; }
}

fn main() {
  let nyan : cat = cat(52u, 99);
  nyan.speak = fn@() { log(error, "meow"); };
}