Skip to content

Commit

Permalink
Allow already bound functions to be bound again.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
msullivan committed Jul 28, 2011
1 parent 63fa765 commit 4de0b3d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
4 changes: 0 additions & 4 deletions src/comp/middle/trans.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]; } }
Expand Down
12 changes: 12 additions & 0 deletions src/test/run-pass/rebind-fn.rs
Original file line number Diff line number Diff line change
@@ -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);
}

0 comments on commit 4de0b3d

Please sign in to comment.