On IRC, jc-denton pointed out the following bug (original example at http://codepad.org/RFICaojj ):
fn memFib(n: int) -> @fn(int) -> int {
let mut memo = @~[0, 1];
let fib = |n: int| -> int {
let mut result: int = - 1;
if n < memo.len() as int {
result = memo[n];
} else {
result = fib(n - 1) + fib(n - 2);
memo.push(result);
}
return result;
};
return fib;
}
This yields a type error because fib's type is inferred to &fn(int) -> int. If you change the declaration of fib to have the explicit type @fn(int) -> int, it compiles.
Possibly related to #4929