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:
parent
63fa765e0e
commit
4de0b3d947
@ -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]; } }
|
||||
|
12
src/test/run-pass/rebind-fn.rs
Normal file
12
src/test/run-pass/rebind-fn.rs
Normal 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);
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user