[fine] Generic garbage

This commit is contained in:
John Doty 2024-02-11 18:44:41 -08:00
parent 692af9f93d
commit aac5c6257f
2 changed files with 40 additions and 1 deletions

View file

@ -0,0 +1,39 @@
class MyIterator {
list: MyList<$0>;
index: i64;
fun next(self) -> $0 or nothing {
if self.index < list.len() {
let result = self.list[self.index];
self.index += 1;
result
} else {
nothing
}
}
}
class MyList {
list: list<$0>;
fun get_iterator(self) -> MyIterator {
new MyIterator {
list: self.list,
index: 0,
}
}
}
fun test() -> f64 {
// Type needs to be inferred as MyList<f64>
let x = MyList { list: [1, 2, 3] };
let sum = 0;
for v in x { // Pick up the iterator methods
sum = sum + v;
}
sum
}
// @ignore undesigned garbage, like all generics
// @no-errors

View file

@ -6,6 +6,6 @@ fun test() {
generic_add(10, 10)
}
// @ignore Feature is undesigned, this is tentative garbage
// @ignore undesigned garbage, like all generics
// @no-errors
// @eval: 20