Enforce mutability declarations in classes; correct shapes for classes

1. Enforce mutability declarations on class fields. Don't allow any
mutation of class fields not declared as mutable (except inside the
constructor).

2. Handle classes correctly in shape (treat classes like records).
This commit is contained in:
Tim Chevalier 2012-03-27 22:08:48 -07:00
parent c9102ee7a1
commit edb747ceed
15 changed files with 187 additions and 40 deletions

View file

@ -1684,8 +1684,8 @@ fn parse_let(p: parser) -> @ast::decl {
fn parse_instance_var(p:parser) -> (ast::class_member, codemap::span) {
let mut is_mutbl = ast::class_immutable;
let lo = p.span.lo;
if eat_word(p, "mut") {
is_mutbl = ast::class_mutable;
if eat_word(p, "mut") || eat_word(p, "mutable") {
is_mutbl = ast::class_mutable;
}
if !is_plain_ident(p) {
p.fatal("expecting ident");