diff options
| author | Graydon Hoare <[email protected]> | 2010-12-02 14:38:24 -0800 |
|---|---|---|
| committer | Graydon Hoare <[email protected]> | 2010-12-02 14:38:32 -0800 |
| commit | b79de6b76cbdcb8f2a8e44433d262c3389f28058 (patch) | |
| tree | 2aa21030462e60e187b61b4276d3dffdcf4472d0 /src | |
| parent | rustc: Remove the overly complex variant_indices and n_ary_variant_indices ta... (diff) | |
| download | rust-b79de6b76cbdcb8f2a8e44433d262c3389f28058.tar.xz rust-b79de6b76cbdcb8f2a8e44433d262c3389f28058.zip | |
Typecheck the box and deref unops properly.
Diffstat (limited to 'src')
| -rw-r--r-- | src/comp/middle/typeck.rs | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/comp/middle/typeck.rs b/src/comp/middle/typeck.rs index 94bd41a6..7f427c32 100644 --- a/src/comp/middle/typeck.rs +++ b/src/comp/middle/typeck.rs @@ -1223,7 +1223,23 @@ fn check_expr(&fn_ctxt fcx, @ast.expr expr) -> @ast.expr { case (ast.expr_unary(?unop, ?oper, _)) { auto oper_1 = check_expr(fcx, oper); auto oper_t = expr_ty(oper_1); - // FIXME: Unops have a bit more subtlety than this. + alt (unop) { + case (ast.box) { oper_t = plain_ty(ty_box(oper_t)); } + case (ast.deref) { + alt (oper_t.struct) { + case (ty_box(?inner_t)) { + oper_t = inner_t; + } + case (_) { + fcx.ccx.sess.span_err + (expr.span, + "dereferencing non-box type: " + + ty_to_str(oper_t)); + } + } + } + case (_) { /* fall through */ } + } ret @fold.respan[ast.expr_](expr.span, ast.expr_unary(unop, oper_1, ast.ann_type(oper_t))); |