Allow already bound functions to be bound again.

This commit just disables the check. All of the real work was in previous
commits that moved the target function into the bindings part of the closure
that is tracked by the tydesc.
Closes #754.
This commit is contained in:
Michael Sullivan 2011-07-27 16:24:00 -07:00
parent 63fa765e0e
commit 4de0b3d947
2 changed files with 12 additions and 4 deletions

View file

@ -4538,10 +4538,6 @@ fn trans_bind(cx: &@block_ctxt, f: &@ast::expr,
fn trans_bind_1(cx: &@block_ctxt, f: &@ast::expr, f_res: &lval_result,
args: &(option::t[@ast::expr])[], id: ast::node_id) ->
result {
if f_res.is_mem {
bcx_ccx(cx).sess.unimpl("re-binding existing function");
}
let bound: (@ast::expr)[] = ~[];
for argopt: option::t[@ast::expr] in args {
alt argopt { none. { } some(e) { bound += ~[e]; } }

View file

@ -0,0 +1,12 @@
// xfail-stage0
fn add(i: int, j: int) -> int { ret i + j; }
fn binder(n: int) -> fn() -> int {
let f = bind add(n, _);
ret bind f(2);
}
fn main() {
binder(5);
let f = binder(1);
assert(f() == 3);
assert(binder(8)() == 10);
}