Can write to immutable parts of a type.

7f84f6d
Opened by Roy Frostig at 2010-07-23 22:29:24

Each pair of lines in the following function:

fn main() {
  let vec[int] v = vec(1, 2, 3);
  v.(1) = 4;

  let tup(int) t = tup(1);
  t._0 = 5;

  let rec(int x) r = rec(x=1);
  r.x = 6;
}

shouldn't make it past the typechecking phase, but do. Also, the following object definition makes it past the typechecker:

obj objy(int x) {
    fn foo() -> () {
        x = 5;
    }
}

but should not. Fix the typechecker to disallow writing to immutable type-parts.

  1. Improve mutability checking. Closed by 44e2dc2789a8b3a19024ec67e25f8bd4d28afdce.

    Graydon Hoare at 2010-07-23 22:29:24