Skip to content

Commit fb0918b

Browse files
committed
---
yaml --- r: 3056 b: refs/heads/master c: 1595c9d h: refs/heads/master v: v3
1 parent 5221592 commit fb0918b

File tree

4 files changed

+47
-14
lines changed

4 files changed

+47
-14
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: d65ad8c31c47a14a2b23e9991a34c02e79ec741e
2+
refs/heads/master: 1595c9d767de72340358028e87d3eb386af0adfe

trunk/src/comp/middle/trans.rs

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5832,30 +5832,32 @@ fn trans_expr_out(&@block_ctxt cx, &@ast::expr e, out_method output)
58325832
ret res(next_cx, sub.val);
58335833
}
58345834

5835-
case (ast::expr_move(?dst, ?src, ?ann)) {
5835+
case (ast::expr_move(?dst, ?src, _)) {
58365836
auto lhs_res = trans_lval(cx, dst);
58375837
assert (lhs_res.is_mem);
58385838
*(lhs_res.res.bcx) = rec(sp=src.span with *(lhs_res.res.bcx));
58395839
auto rhs_res = trans_lval(lhs_res.res.bcx, src);
5840-
auto t = node_ann_type(cx.fcx.lcx.ccx, ann);
5840+
auto t = ty::expr_ty(cx.fcx.lcx.ccx.tcx, src);
58415841
// FIXME: calculate copy init-ness in typestate.
5842-
ret move_val(rhs_res.res.bcx, DROP_EXISTING,
5843-
lhs_res.res.val, rhs_res.res.val, t);
5842+
auto move_res = move_val(rhs_res.res.bcx, DROP_EXISTING,
5843+
lhs_res.res.val, rhs_res.res.val, t);
5844+
ret res(move_res.bcx, C_nil());
58445845
}
58455846

5846-
case (ast::expr_assign(?dst, ?src, ?ann)) {
5847+
case (ast::expr_assign(?dst, ?src, _)) {
58475848
auto lhs_res = trans_lval(cx, dst);
58485849
assert (lhs_res.is_mem);
58495850
*(lhs_res.res.bcx) = rec(sp=src.span with *(lhs_res.res.bcx));
58505851
auto rhs_res = trans_expr(lhs_res.res.bcx, src);
5851-
auto t = node_ann_type(cx.fcx.lcx.ccx, ann);
5852+
auto t = ty::expr_ty(cx.fcx.lcx.ccx.tcx, src);
58525853
// FIXME: calculate copy init-ness in typestate.
5853-
ret copy_val(rhs_res.bcx, DROP_EXISTING,
5854-
lhs_res.res.val, rhs_res.val, t);
5854+
auto copy_res = copy_val(rhs_res.bcx, DROP_EXISTING,
5855+
lhs_res.res.val, rhs_res.val, t);
5856+
ret res(copy_res.bcx, C_nil());
58555857
}
58565858

5857-
case (ast::expr_assign_op(?op, ?dst, ?src, ?ann)) {
5858-
auto t = node_ann_type(cx.fcx.lcx.ccx, ann);
5859+
case (ast::expr_assign_op(?op, ?dst, ?src, _)) {
5860+
auto t = ty::expr_ty(cx.fcx.lcx.ccx.tcx, src);
58595861
auto lhs_res = trans_lval(cx, dst);
58605862
assert (lhs_res.is_mem);
58615863
*(lhs_res.res.bcx) = rec(sp=src.span with *(lhs_res.res.bcx));
@@ -5875,8 +5877,9 @@ fn trans_expr_out(&@block_ctxt cx, &@ast::expr e, out_method output)
58755877
auto v = trans_eager_binop(rhs_res.bcx, op, t,
58765878
lhs_val, rhs_res.val);
58775879
// FIXME: calculate copy init-ness in typestate.
5878-
ret copy_val(v.bcx, DROP_EXISTING,
5879-
lhs_res.res.val, v.val, t);
5880+
auto copy_res = copy_val(v.bcx, DROP_EXISTING,
5881+
lhs_res.res.val, v.val, t);
5882+
ret res(copy_res.bcx, C_nil());
58805883
}
58815884

58825885
case (ast::expr_bind(?f, ?args, ?ann)) {

trunk/src/comp/middle/typeck.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1504,7 +1504,7 @@ fn check_expr(&@fn_ctxt fcx, &@ast::expr expr) {
15041504
auto typ = demand::simple(fcx, sp,
15051505
expr_ty(fcx.ccx.tcx, lhs),
15061506
expr_ty(fcx.ccx.tcx, rhs));
1507-
write::ty_only_fixup(fcx, a.id, typ);
1507+
write::ty_only_fixup(fcx, a.id, ty::mk_nil(fcx.ccx.tcx));
15081508
}
15091509

15101510
// A generic function for checking call expressions
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// xfail-stage0
2+
3+
// Issue 483 - Assignment expressions result in nil
4+
5+
fn test_assign() {
6+
let int x;
7+
8+
let () y = (x = 10);
9+
assert (x == 10);
10+
auto z = (x = 11);
11+
assert (x == 11);
12+
z = (x = 12);
13+
assert ( x == 12);
14+
}
15+
16+
fn test_assign_op() {
17+
let int x = 0;
18+
19+
let () y = (x += 10);
20+
assert (x == 10);
21+
auto z = (x += 11);
22+
assert (x == 21);
23+
z = (x += 12);
24+
assert ( x == 33);
25+
}
26+
27+
fn main() {
28+
test_assign();
29+
test_assign_op();
30+
}

0 commit comments

Comments
 (0)