Port the tests to the decl foo<T> syntax.

This commit is contained in:
Erick Tryzelaar 2011-08-12 06:37:25 -07:00 committed by Graydon Hoare
parent 4abc471390
commit 3520499544
86 changed files with 161 additions and 161 deletions

View file

@ -1,7 +1,7 @@
use std;
import std::vec;
fn ivec_equal[T](v: &[T], u: &[T], element_equality_test: fn(&T, &T) -> bool )
fn ivec_equal<T>(v: &[T], u: &[T], element_equality_test: fn(&T, &T) -> bool )
-> bool {
let Lv = vec::len(v);
if Lv != vec::len(u) { ret false; }
@ -13,7 +13,7 @@ fn ivec_equal[T](v: &[T], u: &[T], element_equality_test: fn(&T, &T) -> bool )
ret true;
}
fn builtin_equal[T](a: &T, b: &T) -> bool { ret a == b; }
fn builtin_equal<T>(a: &T, b: &T) -> bool { ret a == b; }
fn main() {
assert (builtin_equal(5, 5));

View file

@ -7,7 +7,7 @@ Idea: provide functions for 'exhaustive' and 'random' modification of vecs.
two functions, "return the number of possible edits" and "return edit #n"
It would be nice if this could be data-driven, so the two functions could share information:
type vec_modifier = rec(fn (&[T] v, uint i) -> [T] fun, uint lo, uint di);
type vec_modifier = rec(fn (&<T> v, uint i) -> [T] fun, uint lo, uint di);
const [vec_modifier] vec_modifiers = ~[rec(fun=vec_omit, 0u, 1u), ...];
But that gives me "error: internal compiler error unimplemented consts that's not a plain literal".
https://github.com/graydon/rust/issues/570
@ -26,24 +26,24 @@ import std::ivec::slice;
import std::ivec::len;
import std::int;
//fn vec_reverse(&[T] v) -> [T] { ... }
//fn vec_reverse(&<T> v) -> [T] { ... }
fn vec_omit[T](v: &[T], i: uint) -> [T] {
fn vec_omit<T>(v: &[T], i: uint) -> [T] {
slice(v, 0u, i) + slice(v, i + 1u, len(v))
}
fn vec_dup[T](v: &[T], i: uint) -> [T] {
fn vec_dup<T>(v: &[T], i: uint) -> [T] {
slice(v, 0u, i) + ~[v.(i)] + slice(v, i, len(v))
}
fn vec_swadj[T](v: &[T], i: uint) -> [T] {
fn vec_swadj<T>(v: &[T], i: uint) -> [T] {
slice(v, 0u, i) + ~[v.(i + 1u), v.(i)] + slice(v, i + 2u, len(v))
}
fn vec_prefix[T](v: &[T], i: uint) -> [T] { slice(v, 0u, i) }
fn vec_suffix[T](v: &[T], i: uint) -> [T] { slice(v, i, len(v)) }
fn vec_prefix<T>(v: &[T], i: uint) -> [T] { slice(v, 0u, i) }
fn vec_suffix<T>(v: &[T], i: uint) -> [T] { slice(v, i, len(v)) }
fn vec_poke[T](v: &[T], i: uint, x: &T) -> [T] {
fn vec_poke<T>(v: &[T], i: uint, x: &T) -> [T] {
slice(v, 0u, i) + ~[x] + slice(v, i + 1u, len(v))
}
fn vec_insert[T](v: &[T], i: uint, x: &T) -> [T] {
fn vec_insert<T>(v: &[T], i: uint, x: &T) -> [T] {
slice(v, 0u, i) + ~[x] + slice(v, i, len(v))
}
@ -54,7 +54,7 @@ iter ix(skip_low: uint, skip_high: uint, length: uint) -> uint {
}
// Returns a bunch of modified versions of v, some of which introduce new elements (borrowed from xs).
fn vec_edits[T](v: &[T], xs: &[T]) -> [[T]] {
fn vec_edits<T>(v: &[T], xs: &[T]) -> [[T]] {
let edits: [[T]] = ~[];
let Lv: uint = len(v);

View file

@ -2,7 +2,7 @@
// xfail-stage2
// xfail-stage3
// error-pattern: attempted dynamic environment-capture
fn foo[T]() {
fn foo<T>() {
obj bar(b: T) { }
}
fn main() { }
fn main() { }

View file

@ -2,8 +2,8 @@
// error-pattern: Dynamically sized arguments must be passed by alias
mod foo {
fn bar[T](f: T) -> int { ret 17; }
type bar[U, T] = {a: int, b: U, c: T};
fn bar<T>(f: T) -> int { ret 17; }
type bar<U, T> = {a: int, b: U, c: T};
}
fn main() { }
fn main() { }

View file

@ -1,5 +1,5 @@
// error-pattern:Attempt to use a type argument out of scope
fn hd[U](v: &[U]) -> U {
fn hd<U>(v: &[U]) -> U {
fn hd1(w: &[U]) -> U { ret w.(0); }
ret hd1(v);

View file

@ -1,4 +1,4 @@
// error-pattern:mismatched types
// From Issue #778
tag clam[T] { a(T); }
tag clam<T> { a(T); }
fn main() { let c; c = a(c); alt c { a[int](_) { } } }

View file

@ -1,7 +1,7 @@
// error-pattern: Wrong number of type arguments
tag quux[T] { }
tag quux<T> { }
fn foo(c: quux) { assert (false); }
fn main() { fail; }
fn main() { fail; }

View file

@ -1,5 +1,5 @@
// error-pattern:Attempt to use a type argument out of scope
fn foo[T](x: &T) {
fn foo<T>(x: &T) {
fn bar(f: fn(&T) -> T ) { }
}
fn main() { foo(1); }
fn main() { foo(1); }

View file

@ -167,7 +167,7 @@ fn worker(p: _port<request>) {
}
}
fn with_lib_path[T](path: &str, f: fn() -> T ) -> T {
fn with_lib_path<T>(path: &str, f: fn() -> T ) -> T {
let maybe_oldpath = getenv(util::lib_path_env_var());
append_lib_path(path);
let res = f();

View file

@ -6,11 +6,11 @@ fn test00_start(ch: chan_t<int>, message: int) {
type task_id = int;
type port_id = int;
type chan_t[~T] = {
type chan_t<~T> = {
task : task_id,
port : port_id
};
fn send[~T](ch : chan_t<T>, data : -T) { fail; }
fn send<~T>(ch : chan_t<T>, data : -T) { fail; }
fn main() { fail "quux"; }

View file

@ -4,7 +4,7 @@ import std::comm::_chan;
import std::comm::mk_port;
import std::comm::send;
fn echo[~T](c: _chan<T>, oc: _chan<_chan<T>>) {
fn echo<~T>(c: _chan<T>, oc: _chan<_chan<T>>) {
// Tests that the type argument in port gets
// visited
let p = mk_port[T]();

View file

@ -1,7 +1,7 @@
tag option[T] { some(T); none; }
tag option<T> { some(T); none; }
type r[T] = {mutable v: [option<T>]};
type r<T> = {mutable v: [option<T>]};
fn f[T]() -> [T] { ret ~[]; }
fn f<T>() -> [T] { ret ~[]; }
fn main() { let r: r<int> = {mutable v: ~[]}; r.v = f(); }

View file

@ -5,7 +5,7 @@ import std::option::t;
import std::option::none;
import std::option::some;
fn foo[T](y: &option::t<T>) {
fn foo<T>(y: &option::t<T>) {
let x: int;
let rs: [int] = ~[];
/* tests that x doesn't get put in the precondition for the

View file

@ -1,4 +1,4 @@
tag maybe[T] { nothing; just(T); }
tag maybe<T> { nothing; just(T); }
fn foo(x: maybe<int>) {
alt x { nothing. { log_err "A"; } just(a) { log_err "B"; } }

View file

@ -2,6 +2,6 @@
// -*- rust -*-
fn f[T, U](x: &T, y: &U) -> {a: T, b: U} { ret {a: x, b: y}; }
fn f<T, U>(x: &T, y: &U) -> {a: T, b: U} { ret {a: x, b: y}; }
fn main() { log f({x: 3, y: 4, z: 5}, 4).a.x; log f(5, 6).a; }
fn main() { log f({x: 3, y: 4, z: 5}, 4).a.x; log f(5, 6).a; }

View file

@ -1,4 +1,4 @@
fn f[T](x: &[T]) -> T { ret x.(0); }
fn f<T>(x: &[T]) -> T { ret x.(0); }
fn g(act: fn(&[int]) -> int ) -> int { ret act(~[1, 2, 3]); }

View file

@ -1,5 +1,5 @@
fn main() {
fn echo[T](c: int, x: fn(&T)) { log_err "wee"; }
fn echo<T>(c: int, x: fn(&T)) { log_err "wee"; }
let y = bind echo(42, _);

View file

@ -1,5 +1,5 @@
fn main() {
fn echo[T](c: int, x: &[T]) { }
fn echo<T>(c: int, x: &[T]) { }
let y: fn(&[int]) = bind echo(42, _);

View file

@ -1,4 +1,4 @@
fn iter_vec[T](v: &[T], f: &block(&T) ) { for x: T in v { f(x); } }
fn iter_vec<T>(v: &[T], f: &block(&T) ) { for x: T in v { f(x); } }
fn main() {
let v = ~[1, 2, 3, 4, 5, 6, 7];

View file

@ -1,4 +1,4 @@
fn iter_vec[T](v: &[T], f: &block(&T) ) { for x: T in v { f(x); } }
fn iter_vec<T>(v: &[T], f: &block(&T) ) { for x: T in v { f(x); } }
fn main() {
let v = ~[1, 2, 3, 4, 5];

View file

@ -1,8 +1,8 @@
type box[T] = {c: @T};
type box<T> = {c: @T};
fn unbox[T](b: &box<T>) -> T { ret *b.c; }
fn unbox<T>(b: &box<T>) -> T { ret *b.c; }
fn main() {
let foo: int = 17;

View file

@ -1,5 +1,5 @@
fn f[T](i: @int, t: &T) { }
fn f<T>(i: @int, t: &T) { }
fn main() { let x = bind f[char](@0xdeafbeef, _); }
fn main() { let x = bind f[char](@0xdeafbeef, _); }

View file

@ -2,6 +2,6 @@
export foo;
export main;
tag list_cell[T] { cons(@list_cell<T>); }
tag list_cell<T> { cons(@list_cell<T>); }
fn main() { }

View file

@ -2,9 +2,9 @@
// -*- rust -*-
type compare[T] = fn(@T, @T) -> bool ;
type compare<T> = fn(@T, @T) -> bool ;
fn test_generic[T](expected: @T, eq: &compare<T>) {
fn test_generic<T>(expected: @T, eq: &compare<T>) {
let actual: @T = alt true { true { expected } };
assert (eq(expected, actual));
}

View file

@ -2,9 +2,9 @@
// -*- rust -*-
type compare[T] = fn(&T, &T) -> bool ;
type compare<T> = fn(&T, &T) -> bool ;
fn test_generic[T](expected: &T, eq: &compare<T>) {
fn test_generic<T>(expected: &T, eq: &compare<T>) {
let actual: T = alt true { true { expected } };
assert (eq(expected, actual));
}

View file

@ -2,9 +2,9 @@
// -*- rust -*-
type compare[T] = fn(&T, &T) -> bool ;
type compare<T> = fn(&T, &T) -> bool ;
fn test_generic[T](expected: &T, eq: &compare<T>) {
fn test_generic<T>(expected: &T, eq: &compare<T>) {
let actual: T = alt true { true { expected } };
assert (eq(expected, actual));
}

View file

@ -2,9 +2,9 @@
// -*- rust -*-
type compare[T] = fn(@T, @T) -> bool ;
type compare<T> = fn(@T, @T) -> bool ;
fn test_generic[T](expected: @T, eq: &compare<T>) {
fn test_generic<T>(expected: @T, eq: &compare<T>) {
let actual: @T = { expected };
assert (eq(expected, actual));
}

View file

@ -2,9 +2,9 @@
// -*- rust -*-
type compare[T] = fn(&T, &T) -> bool ;
type compare<T> = fn(&T, &T) -> bool ;
fn test_generic[T](expected: &T, eq: &compare<T>) {
fn test_generic<T>(expected: &T, eq: &compare<T>) {
let actual: T = { expected };
assert (eq(expected, actual));
}

View file

@ -4,9 +4,9 @@
// -*- rust -*-
// Tests for standalone blocks as expressions with dynamic type sizes
type compare[T] = fn(&T, &T) -> bool ;
type compare<T> = fn(&T, &T) -> bool ;
fn test_generic[T](expected: &T, eq: &compare<T>) {
fn test_generic<T>(expected: &T, eq: &compare<T>) {
let actual: T = { expected };
assert (eq(expected, actual));
}

View file

@ -9,7 +9,7 @@ fn test_vec() {
}
fn test_generic() {
fn f[T](t: &T) -> T { t }
fn f<T>(t: &T) -> T { t }
assert (f(10) == 10);
}

View file

@ -2,9 +2,9 @@
// -*- rust -*-
type compare[T] = fn(@T, @T) -> bool ;
type compare<T> = fn(@T, @T) -> bool ;
fn test_generic[T](expected: @T, not_expected: @T, eq: &compare<T>) {
fn test_generic<T>(expected: @T, not_expected: @T, eq: &compare<T>) {
let actual: @T = if true { expected } else { not_expected };
assert (eq(expected, actual));
}

View file

@ -2,9 +2,9 @@
// -*- rust -*-
type compare[T] = fn(&T, &T) -> bool ;
type compare<T> = fn(&T, &T) -> bool ;
fn test_generic[T](expected: &T, not_expected: &T, eq: &compare<T>) {
fn test_generic<T>(expected: &T, not_expected: &T, eq: &compare<T>) {
let actual: T = if true { expected } else { not_expected };
assert (eq(expected, actual));
}

View file

@ -4,9 +4,9 @@
// -*- rust -*-
// Tests for if as expressions with dynamic type sizes
type compare[T] = fn(&T, &T) -> bool ;
type compare<T> = fn(&T, &T) -> bool ;
fn test_generic[T](expected: &T, not_expected: &T, eq: &compare<T>) {
fn test_generic<T>(expected: &T, not_expected: &T, eq: &compare<T>) {
let actual: T = if true { expected } else { not_expected };
assert (eq(expected, actual));
}

View file

@ -1,8 +1,8 @@
fn fix_help[A, B](f: @fn(@fn(&A) -> B , &A) -> B , x: &A) -> B {
fn fix_help<A, B>(f: @fn(@fn(&A) -> B , &A) -> B , x: &A) -> B {
ret f(@bind fix_help(f, _), x);
}
fn fix[A, B](f: @fn(@fn(&A) -> B , &A) -> B ) -> @fn(&A) -> B {
fn fix<A, B>(f: @fn(@fn(&A) -> B , &A) -> B ) -> @fn(&A) -> B {
ret @bind fix_help(f, _);
}
@ -15,4 +15,4 @@ fn main() {
let fact = fix(@fact_);
assert (fact(5) == 120);
assert (fact(2) == 2);
}
}

View file

@ -1,6 +1,6 @@
obj ob[K](k: K) {
obj ob<K>(k: K) {
iter foo() -> @{a: K} { put @{a: k}; }
}

View file

@ -1,10 +1,10 @@
fn id[T](t: &T) -> T { ret t; }
fn id<T>(t: &T) -> T { ret t; }
fn main() {
let expected = @100;
let actual = id[@int](expected);
log *actual;
assert (*expected == *actual);
}
}

View file

@ -1,10 +1,10 @@
fn id[T](t: &T) -> T { ret t; }
fn id<T>(t: &T) -> T { ret t; }
fn main() {
let t = {a: 1, b: 2, c: 3, d: 4, e: 5, f: 6, g: 7};
assert (t.f == 6);
let f0 = bind id(t);
assert (f0().f == 6);
}
}

View file

@ -1,6 +1,6 @@
fn id[T](t: &T) -> T { ret t; }
fn id<T>(t: &T) -> T { ret t; }
fn main() {
let t = {_0: 1, _1: 2, _2: 3, _3: 4, _4: 5, _5: 6, _6: 7};
@ -14,4 +14,4 @@ fn main() {
_5: int,
_6: int}](_);
assert (f1(t)._5 == 6);
}
}

View file

@ -1,8 +1,8 @@
fn box[T](x: &{x: T, y: T, z: T}) -> @{x: T, y: T, z: T} { ret @x; }
fn box<T>(x: &{x: T, y: T, z: T}) -> @{x: T, y: T, z: T} { ret @x; }
fn main() {
let x: @{x: int, y: int, z: int} = box[int]({x: 1, y: 2, z: 3});
assert (x.y == 2);
}
}

View file

@ -1,8 +1,8 @@
fn g[X](x: &X) -> X { ret x; }
fn g<X>(x: &X) -> X { ret x; }
fn f[T](t: &T) -> {a: T, b: T} {
fn f<T>(t: &T) -> {a: T, b: T} {
type pair = {a: T, b: T};
let x: pair = {a: t, b: t};
@ -15,4 +15,4 @@ fn main() {
log b.b;
assert (b.a == 10);
assert (b.b == 10);
}
}

View file

@ -1,5 +1,5 @@
fn f[T](t: &T) { let t1: T = t; }
fn f<T>(t: &T) { let t1: T = t; }
fn main() { let x = {x: @10, y: @12}; f(x); }
fn main() { let x = {x: @10, y: @12}; f(x); }

View file

@ -1,8 +1,8 @@
type recbox[T] = {x: @T};
type recbox<T> = {x: @T};
fn reclift[T](t: &T) -> recbox<T> { ret {x: @t}; }
fn reclift<T>(t: &T) -> recbox<T> { ret {x: @t}; }
fn main() {
let foo: int = 17;

View file

@ -1,5 +1,5 @@
fn f[T](x: @T) -> @T { ret x; }
fn f<T>(x: @T) -> @T { ret x; }
fn main() { let x = f(@3); log *x; }
fn main() { let x = f(@3); log *x; }

View file

@ -4,6 +4,6 @@
// -*- rust -*-
// Issue #45: infer type parameters in function applications
fn id[T](x: &T) -> T { ret x; }
fn id<T>(x: &T) -> T { ret x; }
fn main() { let x: int = 42; let y: int = id(x); assert (x == y); }
fn main() { let x: int = 42; let y: int = id(x); assert (x == y); }

View file

@ -3,7 +3,7 @@
// -*- rust -*-
mod foomod {
fn foo[T]() { }
fn foo<T>() { }
}
fn main() { foomod::foo[int](); foomod::foo[int](); }
fn main() { foomod::foo[int](); foomod::foo[int](); }

View file

@ -2,7 +2,7 @@
// -*- rust -*-
fn id[T](x: &T) -> T { ret x; }
fn id<T>(x: &T) -> T { ret x; }
type triple = {x: int, y: int, z: int};
@ -24,4 +24,4 @@ fn main() {
y = q.z;
log y;
assert (x == y);
}
}

View file

@ -4,6 +4,6 @@
// Contrived example? No. It showed up in rustc's resolve pass.
iter i() { put (); }
fn foo[T](t: &T) { let x: int = 10; for each j: () in i() { log x; } }
fn foo<T>(t: &T) { let x: int = 10; for each j: () in i() { log x; } }
fn main() { foo(0xdeadbeef_u); }

View file

@ -1,4 +1,4 @@
tag wrapper[T] { wrapped(T); }
tag wrapper<T> { wrapped(T); }
fn main() { let w = wrapped(~[1, 2, 3, 4, 5]); }

View file

@ -1,3 +1,3 @@
fn f[T](v: @T) { }
fn f<T>(v: @T) { }
fn main() { f(@~[1, 2, 3, 4, 5]); }

View file

@ -1,6 +1,6 @@
obj handle[T](data: T) {
obj handle<T>(data: T) {
fn get() -> T { ret data; }
}

View file

@ -1,6 +1,6 @@
obj buf[T](data: {_0: T, _1: T, _2: T}) {
obj buf<T>(data: {_0: T, _1: T, _2: T}) {
fn get(i: int) -> T {
if i == 0 {
ret data._0;

View file

@ -1,6 +1,6 @@
tag list[T] { cons(@T, @list<T>); nil; }
tag list<T> { cons(@T, @list<T>); nil; }
fn main() {
let a: list<int> =

View file

@ -1,8 +1,8 @@
tag foo[T] { arm(T); }
tag foo<T> { arm(T); }
fn altfoo[T](f: &foo<T>) {
fn altfoo<T>(f: &foo<T>) {
let hit = false;
alt f { arm[T](x) { log "in arm"; hit = true; } }
assert (hit);

View file

@ -2,6 +2,6 @@
// This causes memory corruption in stage0.
tag thing[K] { some(K); }
tag thing<K> { some(K); }
fn main() { let x = some("hi"); }
fn main() { let x = some("hi"); }

View file

@ -1,5 +1,5 @@
tag clam[T] { a(T); }
tag clam<T> { a(T); }
fn main() { let c = a(3); }
fn main() { let c = a(3); }

View file

@ -2,7 +2,7 @@
// -*- rust -*-
tag noption[T] { some(T); }
tag noption<T> { some(T); }
fn main() {
let nop: noption<int> = some[int](5);

View file

@ -1,5 +1,5 @@
tag option[T] { some(@T); none; }
tag option<T> { some(@T); none; }
fn main() { let a: option<int> = some[int](@10); a = none[int]; }

View file

@ -4,10 +4,10 @@ fn mk() -> int { ret 1; }
fn chk(a: &int) { log a; assert (a == 1); }
fn apply[T](produce: fn() -> T , consume: fn(&T) ) { consume(produce()); }
fn apply<T>(produce: fn() -> T , consume: fn(&T) ) { consume(produce()); }
fn main() {
let produce: fn() -> int = mk;
let consume: fn(&int) = chk;
apply[int](produce, consume);
}
}

View file

@ -1,4 +1,4 @@
fn get_third[T](t: &(T, T, T)) -> T {
fn get_third<T>(t: &(T, T, T)) -> T {
let (_, _, x) = t;
ret x;
}
@ -7,4 +7,4 @@ fn main() {
log get_third((1, 2, 3));
assert (get_third((1, 2, 3)) == 3);
assert (get_third((5u8, 6u8, 7u8)) == 7u8);
}
}

View file

@ -1,9 +1,9 @@
type foo[T] = {a: T};
type foo<T> = {a: T};
type bar[T] = foo<T>;
type bar<T> = foo<T>;
fn takebar[T](b: &bar<T>) { }
fn takebar<T>(b: &bar<T>) { }
fn main() { }

View file

@ -1,6 +1,6 @@
type pair[T] = {x: T, y: T};
type pair<T> = {x: T, y: T};
fn main() {
let x: pair<int> = {x: 10, y: 12};

View file

@ -3,7 +3,7 @@
import rusti::ivec_len;
native "rust-intrinsic" mod rusti {
fn ivec_len[T](v: &[T]) -> uint;
fn ivec_len<T>(v: &[T]) -> uint;
}
fn main() {

View file

@ -1,5 +1,5 @@
fn quux[T](x: &T) -> T { let f = id[T]; ret f(x); }
fn quux<T>(x: &T) -> T { let f = id[T]; ret f(x); }
fn id[T](x: &T) -> T { ret x; }
fn id<T>(x: &T) -> T { ret x; }
fn main() { assert (quux(10) == 10); }
fn main() { assert (quux(10) == 10); }

View file

@ -1,4 +1,4 @@
fn double[T](a: &T) -> [T] { ret ~[a] + ~[a]; }
fn double<T>(a: &T) -> [T] { ret ~[a] + ~[a]; }
fn double_int(a: int) -> [int] { ret ~[a] + ~[a]; }

View file

@ -1,5 +1,5 @@
fn leaky[T](t: &T) { }
fn leaky<T>(t: &T) { }
fn main() { let x = @10; leaky[@int](x); }
fn main() { let x = @10; leaky[@int](x); }

View file

@ -1,8 +1,8 @@
tag myvec[X] = [X];
tag myvec<X> = [X];
fn myvec_deref[X](mv: &myvec<X>) -> [X] { ret *mv; }
fn myvec_deref<X>(mv: &myvec<X>) -> [X] { ret *mv; }
fn myvec_elt[X](mv: &myvec<X>) -> X { ret mv.(0); }
fn myvec_elt<X>(mv: &myvec<X>) -> X { ret mv.(0); }
fn main() {
let mv = myvec(~[1, 2, 3]);

View file

@ -2,11 +2,11 @@
// -*- rust -*-
tag clam[T] { signed(int); unsigned(uint); }
tag clam<T> { signed(int); unsigned(uint); }
fn getclam[T]() -> clam<T> { ret signed[T](42); }
fn getclam<T>() -> clam<T> { ret signed[T](42); }
obj impatience[T]() {
obj impatience<T>() {
fn moreclam() -> clam<T> { be getclam[T](); }
}

View file

@ -1,4 +1,4 @@
resource finish[T](arg: {val: T, fin: fn(&T) }) { arg.fin(arg.val); }
resource finish<T>(arg: {val: T, fin: fn(&T) }) { arg.fin(arg.val); }
fn main() {
let box = @mutable 10;
@ -6,4 +6,4 @@ fn main() {
{ let i <- finish({val: box, fin: dec_box}); }
assert (*box == 9);
}
}

View file

@ -7,7 +7,7 @@ resource close_res(i: closable) {
*i = false;
}
tag option[T] { none; some(T); }
tag option<T> { none; some(T); }
fn sink(res: option<close_res>) {}

View file

@ -1,7 +1,7 @@
tag option[T] { none; some(T); }
tag option<T> { none; some(T); }
fn f[T]() -> option<T> { ret none; }
fn f<T>() -> option<T> { ret none; }
fn main() { f[int](); }

View file

@ -4,9 +4,9 @@ import std::comm::send;
import std::comm::mk_port;
// tests that ctrl's type gets inferred properly
type command[K, V] = {key: K, val: V};
type command<K, V> = {key: K, val: V};
fn cache_server[K, V](c: _chan<_chan<command<K, V>>>) {
fn cache_server<K, V>(c: _chan<_chan<command<K, V>>>) {
let ctrl = mk_port[_chan<command<K, V>>]();
send(c, ctrl.mk_chan());
}

View file

@ -10,7 +10,7 @@ fn foo(c: [int]) {
}
}
tag t[T] { none; some(T); }
tag t<T> { none; some(T); }
fn main() {
let x = 10;

View file

@ -1,5 +1,5 @@
tag opt[T] { none; }
tag opt<T> { none; }
fn main() { let x = none[int]; alt x { none[int]. { log "hello world"; } } }
fn main() { let x = none[int]; alt x { none[int]. { log "hello world"; } } }

View file

@ -1,5 +1,5 @@
tag clam[T] { a(T); }
tag clam<T> { a(T); }
fn main() { let c = a(2); alt c { a[int](_) { } } }
fn main() { let c = a(2); alt c { a[int](_) { } } }

View file

@ -1,5 +1,5 @@
tag clam[T] { a(T); }
tag clam<T> { a(T); }
fn main() { }
fn main() { }

View file

@ -2,9 +2,9 @@
// -*- rust -*-
tag clam[T] { a(T, int); b; }
tag clam<T> { a(T, int); b; }
fn uhoh[T](v: &[clam<T>]) {
fn uhoh<T>(v: &[clam<T>]) {
alt v.(1) {
a[T](t, u) { log "incorrect"; log u; fail; }
b[T]. { log "correct"; }

View file

@ -1,4 +1,4 @@
fn swap[@T](v: &[mutable T], i: int, j: int) { v.(i) <-> v.(j); }
fn swap<@T>(v: &[mutable T], i: int, j: int) { v.(i) <-> v.(j); }
fn main() {
let a: [mutable int] = ~[mutable 0, 1, 2, 3, 4, 5, 6];

View file

@ -2,8 +2,8 @@
tag colour { red; green; }
obj foo[T]() {
obj foo<T>() {
fn meth(x: &T) { }
}
fn main() { foo[colour]().meth(red); }
fn main() { foo[colour]().meth(red); }

View file

@ -1,6 +1,6 @@
fn p_foo[T](pinned: &T) { }
fn s_foo[@T](shared: &T) { }
fn u_foo[~T](unique: &T) { }
fn p_foo<T>(pinned: &T) { }
fn s_foo<@T>(shared: &T) { }
fn u_foo<~T>(unique: &T) { }
resource r(i: int) { }
@ -22,4 +22,4 @@ fn main() {
//u_foo(~10);
u_foo(10);
}
}

View file

@ -1,5 +1,5 @@
type lteq[T] = fn(&T) -> bool ;
type lteq<T> = fn(&T) -> bool ;
fn main(args: [str]) { }

View file

@ -5,7 +5,7 @@ iter range(lo: uint, hi: uint) -> uint {
while lo_ < hi { put lo_; lo_ += 1u; }
}
fn create_index[T](index: &[{a: T, b: uint}], hash_fn: fn(&T) -> uint ) {
fn create_index<T>(index: &[{a: T, b: uint}], hash_fn: fn(&T) -> uint ) {
for each i: uint in range(0u, 256u) { let bucket: [T] = ~[]; }
}

View file

@ -4,8 +4,8 @@
use std;
import std::unsafe;
fn null[T]() -> *T { unsafe::reinterpret_cast(0) }
fn null<T>() -> *T { unsafe::reinterpret_cast(0) }
fn main() {
null[int]();
}
}

View file

@ -1,11 +1,11 @@
fn foo[T](o: &myoption<T>) -> int {
fn foo<T>(o: &myoption<T>) -> int {
let x: int = 5;
alt o { none[T]. { } some[T](t) { x += 1; } }
ret x;
}
tag myoption[T] { none; some(T); }
tag myoption<T> { none; some(T); }
fn main() { log 5; }

View file

@ -1,11 +1,11 @@
fn foo[T](o: &myoption<T>) -> int {
fn foo<T>(o: &myoption<T>) -> int {
let x: int;
alt o { none[T]. { fail; } some[T](t) { x = 5; } }
ret x;
}
tag myoption[T] { none; some(T); }
tag myoption<T> { none; some(T); }
fn main() { log 5; }

View file

@ -1,5 +1,5 @@
fn push[T](v: &mutable [mutable? T], t: &T) { v += ~[t]; }
fn push<T>(v: &mutable [mutable? T], t: &T) { v += ~[t]; }
fn main() { let v = ~[1, 2, 3]; push(v, 1); }

View file

@ -79,9 +79,9 @@ fn test_boxes(a: @int, b: @int, c: @int, d: @int) {
assert (deq.get(3) == d);
}
type eqfn[T] = fn(&T, &T) -> bool ;
type eqfn<T> = fn(&T, &T) -> bool ;
fn test_parameterized[@T](e: eqfn<T>, a: &T, b: &T, c: &T, d: &T) {
fn test_parameterized<@T>(e: eqfn<T>, a: &T, b: &T, c: &T, d: &T) {
let deq: deque::t<T> = deque::create[T]();
assert (deq.size() == 0u);
deq.add_front(a);
@ -113,7 +113,7 @@ fn test_parameterized[@T](e: eqfn<T>, a: &T, b: &T, c: &T, d: &T) {
tag taggy { one(int); two(int, int); three(int, int, int); }
tag taggypar[@T] { onepar(int); twopar(int, int); threepar(int, int, int); }
tag taggypar<@T> { onepar(int); twopar(int, int); threepar(int, int, int); }
type reccy = {x: int, y: int, t: taggy};
@ -138,7 +138,7 @@ fn test() {
}
}
}
fn taggypareq[@T](a: &taggypar<T>, b: &taggypar<T>) -> bool {
fn taggypareq<@T>(a: &taggypar<T>, b: &taggypar<T>) -> bool {
alt a {
onepar[T](a1) {
alt b { onepar[T](b1) { ret a1 == b1; } _ { ret false; } }