2012-04-17 12:05:28 -05:00
|
|
|
fn with<T>(t: T, f: fn(T)) { f(t) }
|
|
|
|
|
2012-07-12 11:36:56 -05:00
|
|
|
fn nested(x: &x/int) { // (1)
|
2012-06-26 15:55:56 -05:00
|
|
|
do with(
|
2012-07-12 11:36:56 -05:00
|
|
|
fn&(x: &x/int, // Refers to the region `x` at (1)
|
|
|
|
y: &y/int, // A fresh region `y` (2)
|
|
|
|
z: fn(x: &x/int, // Refers to `x` at (1)
|
|
|
|
y: &y/int, // Refers to `y` at (2)
|
|
|
|
z: &z/int) -> &z/int) // A fresh region `z` (3)
|
|
|
|
-> &x/int {
|
2012-04-17 12:05:28 -05:00
|
|
|
|
2012-07-12 11:36:56 -05:00
|
|
|
if false { ret z(x, x, x); } //~ ERROR mismatched types: expected `&y/int` but found `&x/int`
|
|
|
|
if false { ret z(x, x, y); } //~ ERROR mismatched types: expected `&y/int` but found `&x/int`
|
|
|
|
//~^ ERROR mismatched types: expected `&x/int` but found `&y/int`
|
2012-04-17 12:05:28 -05:00
|
|
|
if false { ret z(x, y, x); }
|
2012-07-12 11:36:56 -05:00
|
|
|
if false { ret z(x, y, y); } //~ ERROR mismatched types: expected `&x/int` but found `&y/int`
|
|
|
|
if false { ret z(y, x, x); } //~ ERROR mismatched types: expected `&x/int` but found `&y/int`
|
|
|
|
//~^ ERROR mismatched types: expected `&y/int` but found `&x/int`
|
|
|
|
if false { ret z(y, x, y); } //~ ERROR mismatched types: expected `&x/int` but found `&y/int`
|
|
|
|
//~^ ERROR mismatched types: expected `&y/int` but found `&x/int`
|
|
|
|
//~^^ ERROR mismatched types: expected `&x/int` but found `&y/int`
|
|
|
|
if false { ret z(y, y, x); } //~ ERROR mismatched types: expected `&x/int` but found `&y/int`
|
|
|
|
if false { ret z(y, y, y); } //~ ERROR mismatched types: expected `&x/int` but found `&y/int`
|
|
|
|
//~^ ERROR mismatched types: expected `&x/int` but found `&y/int`
|
2012-04-17 12:05:28 -05:00
|
|
|
fail;
|
|
|
|
}
|
2012-06-30 18:19:07 -05:00
|
|
|
) |foo| {
|
2012-04-17 18:03:23 -05:00
|
|
|
|
2012-07-12 11:36:56 -05:00
|
|
|
let a: &x/int = foo(x, x, |_x, _y, z| z );
|
|
|
|
let b: &x/int = foo(x, a, |_x, _y, z| z );
|
|
|
|
let c: &x/int = foo(a, a, |_x, _y, z| z );
|
2012-04-17 12:05:28 -05:00
|
|
|
|
2012-06-18 15:41:52 -05:00
|
|
|
let z = 3i;
|
2012-07-12 11:36:56 -05:00
|
|
|
let d: &x/int = foo(x, x, |_x, _y, z| z );
|
|
|
|
let e: &x/int = foo(x, &z, |_x, _y, z| z );
|
|
|
|
let f: &x/int = foo(&z, &z, |_x, _y, z| z ); //~ ERROR mismatched types: expected `&x/int` but found
|
2012-04-17 12:05:28 -05:00
|
|
|
|
2012-07-12 11:36:56 -05:00
|
|
|
foo(x, &z, |x, _y, _z| x ); //~ ERROR mismatched types: expected `&z/int` but found `&x/int`
|
|
|
|
foo(x, &z, |_x, y, _z| y ); //~ ERROR mismatched types: expected `&z/int` but found `&<block at
|
2012-04-17 12:05:28 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {}
|