2 struct Cons<T> {head:isize, tail:T}
3 trait Dot {fn dot(&self, other:Self) -> isize;}
5 fn dot(&self, _:Nil) -> isize {0}
7 impl<T:Dot> Dot for Cons<T> {
8 fn dot(&self, other:Cons<T>) -> isize {
9 self.head * other.head + self.tail.dot(other.tail)
12 fn test<T:Dot> (n:isize, i:isize, first:T, second:T) ->isize { //~ ERROR recursion limit
13 match n { 0 => {first.dot(second)}
14 // FIXME(#4287) Error message should be here. It should be
15 // a type error to instantiate `test` at a type other than T.
16 _ => {test (n-1, i+1, Cons {head:2*i+1, tail:first}, Cons{head:i*i, tail:second})}
20 let n = test(1, 0, Nil::NilValue, Nil::NilValue);