generate correct constraints for assignments

This commit is contained in:
Niko Matsakis 2012-03-26 13:54:19 -07:00
parent 76d0a13ae5
commit f682b99e36
2 changed files with 7 additions and 2 deletions

View File

@ -2414,8 +2414,8 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, expr: @ast::expr, unify: unifier,
// A generic function for checking assignment expressions
fn check_assignment(fcx: @fn_ctxt, _sp: span, lhs: @ast::expr,
rhs: @ast::expr, id: ast::node_id) -> bool {
let t = next_ty_var(fcx);
let bot = check_expr_with(fcx, lhs, t) | check_expr_with(fcx, rhs, t);
let mut bot = check_expr(fcx, lhs);
bot |= check_expr_with(fcx, rhs, expr_ty(fcx.ccx.tcx, lhs));
write_ty(fcx.ccx.tcx, id, ty::mk_nil(fcx.ccx.tcx));
ret bot;
}

View File

@ -0,0 +1,5 @@
fn main() {
let mut x: [mut int] = [mut 3];
let y: [int] = [3];
x = y; //! ERROR values differ in mutability
}