Skip to content

Commit 646cab6

Browse files
committed
---
yaml --- r: 666 b: refs/heads/master c: 6cfeac1 h: refs/heads/master v: v3
1 parent c59662a commit 646cab6

File tree

3 files changed

+18
-7
lines changed

3 files changed

+18
-7
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: a4a0c6ad1e76e43f688edbed58347dc4b79ea852
2+
refs/heads/master: 6cfeac162d4562b07a540af0959cc1d39c882f6d

trunk/src/boot/me/trans.ml

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1006,6 +1006,21 @@ let trans_visitor
10061006
trans_cond_fail "bounds check" jmp;
10071007
based elt_reg
10081008

1009+
and trans_lval_item
1010+
(lv:Ast.lval)
1011+
: (Il.cell * Ast.ty) =
1012+
assert (lval_base_is_item cx lv);
1013+
let ty = lval_ty cx lv in
1014+
let item = lval_item cx lv in
1015+
check_concrete item.node.Ast.decl_params ();
1016+
match item.node.Ast.decl_item with
1017+
Ast.MOD_ITEM_const (_, Some e) ->
1018+
(Il.Reg (force_to_reg (trans_expr e)), ty)
1019+
| _ ->
1020+
bug ()
1021+
"trans_lval_full called on unsupported item lval '%a'"
1022+
Ast.sprintf_lval lv
1023+
10091024
and trans_lval_full
10101025
(initializing:bool)
10111026
(lv:Ast.lval)
@@ -1062,12 +1077,7 @@ let trans_visitor
10621077
else
10631078
if initializing
10641079
then err None "init item"
1065-
else
1066-
begin
1067-
assert (lval_base_is_item cx lv);
1068-
bug ()
1069-
"trans_lval_full called on item lval '%a'" Ast.sprintf_lval lv
1070-
end
1080+
else trans_lval_item lv
10711081

10721082
and trans_lval_maybe_init
10731083
(initializing:bool)

trunk/src/test/run-pass/const.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
const int i = 10;
22

33
fn main() {
4+
log i;
45
}

0 commit comments

Comments
 (0)