rust/src/test/compile-fail/issue-1896-1.rs
Niko Matsakis b0ed151539 Cleanup how we handle proto in types, remove unsound subtyping
Fixes #1896 which was never truly fixed, just masked.
The given tests would have failed had they used `~fn()` and
not `@fn()`.  They now result in compilation errors.

Fixes #2978.

Necessary first step for #2202, #2263.
2012-11-06 08:56:29 -08:00

13 lines
283 B
Rust

type boxedFn = { theFn: fn () -> uint };
fn createClosure (closedUint: uint) -> boxedFn {
{ theFn: fn@ () -> uint { closedUint } } //~ ERROR mismatched types
}
fn main () {
let aFn: boxedFn = createClosure(10);
let myInt: uint = aFn.theFn();
assert myInt == 10;
}