Skip to content

Commit 05871be

Browse files
committed
---
yaml --- r: 321 b: refs/heads/master c: ae515c0 h: refs/heads/master i: 319: 9654e24 v: v3
1 parent a7d0ada commit 05871be

File tree

4 files changed

+44
-18
lines changed

4 files changed

+44
-18
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: fde9ca0937171b77542028ef433fddf979aa506b
2+
refs/heads/master: ae515c017c0aadb2a4c691804f1bc3b8b343dd67

trunk/src/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,7 @@ TEST_XFAILS_LLVM := $(addprefix test/run-pass/, \
386386
acyclic-unwind.rs \
387387
alt-pattern-simple.rs \
388388
alt-tag.rs \
389+
autoderef-full-lval.rs \
389390
autoderef-objfn.rs \
390391
basic.rs \
391392
bind-obj-ctor.rs \

trunk/src/boot/me/trans.ml

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -973,33 +973,40 @@ let trans_visitor
973973
(lv:Ast.lval)
974974
: (Il.cell * Ast.ty) =
975975

976-
let rec trans_slot_lval_full (initializing:bool) lv =
976+
let rec trans_slot_lval_full (initializing:bool) (outermost:bool) lv =
977977
let (cell, ty) =
978978
match lv with
979979
Ast.LVAL_ext (base, comp) ->
980980
let (base_cell, base_ty) =
981-
trans_slot_lval_full initializing base
981+
trans_slot_lval_full initializing false base
982982
in
983983
trans_slot_lval_ext initializing base_ty base_cell comp
984984

985-
| Ast.LVAL_base nbi ->
985+
| Ast.LVAL_base _ ->
986986
let sloti = lval_base_to_slot cx lv in
987987
let cell = cell_of_block_slot sloti.id in
988988
let ty = slot_ty sloti.node in
989989
let cell = deref_slot initializing cell sloti.node in
990-
let dctrl =
991-
(* If this fails, type didn't visit the lval, and we
992-
* don't know whether to auto-deref its base. Crashing
993-
* here is best. Compiler bug.
994-
*)
995-
match htab_search cx.ctxt_auto_deref_lval nbi.id with
996-
None ->
997-
bugi cx nbi.id
998-
"Lval without auto-deref info; bad typecheck?"
999-
| Some true -> DEREF_all_boxes
1000-
| Some false -> DEREF_none
1001-
in
1002-
deref_ty dctrl initializing cell ty
990+
(cell, ty)
991+
in
992+
let (cell, ty) =
993+
if outermost
994+
then
995+
let id = lval_base_id lv in
996+
let dctrl =
997+
(* If this fails, type didn't visit the lval, and we
998+
* don't know whether to auto-deref the entire lval.
999+
* Crashing here is best. Compiler bug.
1000+
*)
1001+
match htab_search cx.ctxt_auto_deref_lval id with
1002+
None ->
1003+
bugi cx id
1004+
"Lval without auto-deref info; bad typecheck?"
1005+
| Some true -> DEREF_all_boxes
1006+
| Some false -> DEREF_none
1007+
in
1008+
deref_ty dctrl initializing cell ty
1009+
else (cell, ty)
10031010
in
10041011
iflog
10051012
begin
@@ -1013,7 +1020,7 @@ let trans_visitor
10131020

10141021
in
10151022
if lval_is_slot cx lv
1016-
then trans_slot_lval_full initializing lv
1023+
then trans_slot_lval_full initializing true lv
10171024
else
10181025
if initializing
10191026
then err None "init item"
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// -*- rust -*-
2+
3+
type clam = rec(@int x, @int y);
4+
type fish = tup(@int);
5+
6+
fn main() {
7+
let clam a = rec(x=@1, y=@2);
8+
let clam b = rec(x=@10, y=@20);
9+
let int z = a.x + b.y;
10+
log z;
11+
check (z == 21);
12+
13+
let fish forty = tup(@40);
14+
let fish two = tup(@2);
15+
let int answer = forty._0 + two._0;
16+
log answer;
17+
check (answer == 42);
18+
}

0 commit comments

Comments
 (0)