Skip to content

Commit d74a7a8

Browse files
committed
Fail with an informative error when trying to bind a method
Issue #435
1 parent d243ea5 commit d74a7a8

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

src/comp/middle/trans.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2983,7 +2983,7 @@ type generic_info =
29832983
type lval_result = {bcx: @block_ctxt,
29842984
val: ValueRef,
29852985
is_mem: bool};
2986-
tag callee_env { some_env(ValueRef); null_env; is_closure; }
2986+
tag callee_env { obj_env(ValueRef); null_env; is_closure; }
29872987
type lval_maybe_callee = {bcx: @block_ctxt,
29882988
val: ValueRef,
29892989
is_mem: bool,
@@ -3191,7 +3191,7 @@ fn trans_field_inner(cx: @block_ctxt, sp: span, v: ValueRef, t0: ty::t,
31913191
ret_ty, 0u);
31923192
v = Load(r.bcx, PointerCast(r.bcx, v, T_ptr(T_ptr(ll_fn_ty))));
31933193
ret {bcx: r.bcx, val: v, is_mem: true,
3194-
env: some_env(r.val), generic: none};
3194+
env: obj_env(r.val), generic: none};
31953195
}
31963196
_ { bcx_ccx(cx).sess.unimpl("field variant in trans_field"); }
31973197
}
@@ -3342,15 +3342,15 @@ fn trans_lval(cx: @block_ctxt, e: @ast::expr) -> lval_result {
33423342

33433343
fn maybe_add_env(bcx: @block_ctxt, c: lval_maybe_callee)
33443344
-> (bool, ValueRef) {
3345-
if c.env == is_closure {
3346-
(c.is_mem, c.val)
3347-
} else {
3348-
let env = alt c.env {
3349-
null_env. { null_env_ptr(bcx) }
3350-
some_env(e) { e }
3351-
};
3345+
alt c.env {
3346+
is_closure. { (c.is_mem, c.val) }
3347+
obj_env(_) {
3348+
fail "Taking the value of a method does not work yet (issue #435)";
3349+
}
3350+
null_env. {
33523351
let llfnty = llvm::LLVMGetElementType(val_ty(c.val));
3353-
(false, create_real_fn_pair(bcx, llfnty, c.val, env))
3352+
(false, create_real_fn_pair(bcx, llfnty, c.val, null_env_ptr(bcx)))
3353+
}
33543354
}
33553355
}
33563356

@@ -3904,7 +3904,7 @@ fn trans_call(in_cx: @block_ctxt, f: @ast::expr,
39043904
null_env. {
39053905
llenv = llvm::LLVMGetUndef(T_opaque_closure_ptr(*bcx_ccx(cx)));
39063906
}
3907-
some_env(e) { llenv = e; }
3907+
obj_env(e) { llenv = e; }
39083908
is_closure. {
39093909
// It's a closure. Have to fetch the elements
39103910
if f_res.is_mem { faddr = load_if_immediate(bcx, faddr, fn_expr_ty); }

0 commit comments

Comments
 (0)