Skip to content

Commit b79de6b

Browse files
committed
Typecheck the box and deref unops properly.
1 parent 376b35e commit b79de6b

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

src/comp/middle/typeck.rs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1223,7 +1223,23 @@ fn check_expr(&fn_ctxt fcx, @ast.expr expr) -> @ast.expr {
12231223
case (ast.expr_unary(?unop, ?oper, _)) {
12241224
auto oper_1 = check_expr(fcx, oper);
12251225
auto oper_t = expr_ty(oper_1);
1226-
// FIXME: Unops have a bit more subtlety than this.
1226+
alt (unop) {
1227+
case (ast.box) { oper_t = plain_ty(ty_box(oper_t)); }
1228+
case (ast.deref) {
1229+
alt (oper_t.struct) {
1230+
case (ty_box(?inner_t)) {
1231+
oper_t = inner_t;
1232+
}
1233+
case (_) {
1234+
fcx.ccx.sess.span_err
1235+
(expr.span,
1236+
"dereferencing non-box type: "
1237+
+ ty_to_str(oper_t));
1238+
}
1239+
}
1240+
}
1241+
case (_) { /* fall through */ }
1242+
}
12271243
ret @fold.respan[ast.expr_](expr.span,
12281244
ast.expr_unary(unop, oper_1,
12291245
ast.ann_type(oper_t)));

0 commit comments

Comments
 (0)