[fine] Support assignment to member, loops with iterators

Hmm it's starting to look like something.
This commit is contained in:
John Doty 2024-02-07 01:57:41 -08:00
parent 3415b1a3f6
commit 239e859eaf
7 changed files with 360 additions and 171 deletions

View file

@ -1,3 +1,21 @@
class Finished {}
let FINISHED = new Finished {};
class Iterator {
current: f64;
fun next(self) -> f64 or Finished {
if self.current < 10 {
let result = self.current;
self.current = self.current + 1;
return result;
}
FINISHED
}
}
fun test() -> f64 {
let result = 1;
let i = 0;
@ -5,8 +23,15 @@ fun test() -> f64 {
result = result * 2;
i = i + 1;
}
result
let sum = 0;
let it = new Iterator { current: 0 };
while it.next() is v: f64 {
sum = sum + v;
}
result + sum
}
// @no-errors
// @eval: Float(1024.0)
// @eval: Float(1069.0)