Skip to content

Commit 4de0b3d

Browse files
committed
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.
1 parent 63fa765 commit 4de0b3d

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

src/comp/middle/trans.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4538,10 +4538,6 @@ fn trans_bind(cx: &@block_ctxt, f: &@ast::expr,
45384538
fn trans_bind_1(cx: &@block_ctxt, f: &@ast::expr, f_res: &lval_result,
45394539
args: &(option::t[@ast::expr])[], id: ast::node_id) ->
45404540
result {
4541-
if f_res.is_mem {
4542-
bcx_ccx(cx).sess.unimpl("re-binding existing function");
4543-
}
4544-
45454541
let bound: (@ast::expr)[] = ~[];
45464542
for argopt: option::t[@ast::expr] in args {
45474543
alt argopt { none. { } some(e) { bound += ~[e]; } }

src/test/run-pass/rebind-fn.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// xfail-stage0
2+
fn add(i: int, j: int) -> int { ret i + j; }
3+
fn binder(n: int) -> fn() -> int {
4+
let f = bind add(n, _);
5+
ret bind f(2);
6+
}
7+
fn main() {
8+
binder(5);
9+
let f = binder(1);
10+
assert(f() == 3);
11+
assert(binder(8)() == 10);
12+
}

0 commit comments

Comments
 (0)