Skip to content

Commit 52f2a9a

Browse files
committed
Test case to make sure typestate checks the body of class constructors
1 parent 90cf9e0 commit 52f2a9a

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// error-pattern:unsatisfied precondition
2+
class cat {
3+
priv {
4+
let mutable meows : uint;
5+
}
6+
7+
let how_hungry : int;
8+
9+
fn eat() {
10+
how_hungry -= 5;
11+
}
12+
13+
new(in_x : uint, in_y : int) {
14+
let foo;
15+
meows = in_x + (in_y as uint);
16+
how_hungry = foo;
17+
}
18+
}
19+
20+
fn main() {
21+
let nyan : cat = cat(52u, 99);
22+
nyan.eat();
23+
}

0 commit comments

Comments
 (0)