Improve mutability checking. Closes #118.
This commit is contained in:
parent
8bd8413906
commit
44e2dc2789
9 changed files with 60 additions and 15 deletions
|
|
@ -1,6 +1,6 @@
|
|||
// -*- rust -*-
|
||||
|
||||
// error-pattern: writing to non-mutable slot
|
||||
// error-pattern: writing to immutable type
|
||||
|
||||
type point = rec(int x, int y, int z);
|
||||
|
||||
|
|
|
|||
8
src/test/compile-fail/writing-to-immutable-obj.rs
Normal file
8
src/test/compile-fail/writing-to-immutable-obj.rs
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
// error-pattern: writing to immutable type
|
||||
obj objy(int x) {
|
||||
fn foo() -> () {
|
||||
x = 5;
|
||||
}
|
||||
}
|
||||
fn main() {
|
||||
}
|
||||
5
src/test/compile-fail/writing-to-immutable-rec.rs
Normal file
5
src/test/compile-fail/writing-to-immutable-rec.rs
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
// error-pattern: writing to immutable type
|
||||
fn main() {
|
||||
let rec(int x) r = rec(x=1);
|
||||
r.x = 6;
|
||||
}
|
||||
5
src/test/compile-fail/writing-to-immutable-tup.rs
Normal file
5
src/test/compile-fail/writing-to-immutable-tup.rs
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
// error-pattern: writing to immutable type
|
||||
fn main() {
|
||||
let tup(int) t = tup(1);
|
||||
t._0 = 5;
|
||||
}
|
||||
5
src/test/compile-fail/writing-to-immutable-vec.rs
Normal file
5
src/test/compile-fail/writing-to-immutable-vec.rs
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
// error-pattern: writing to immutable type
|
||||
fn main() {
|
||||
let vec[int] v = vec(1, 2, 3);
|
||||
v.(1) = 4;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue