Skip to content

Commit

Permalink
frontend: Remove register in visit_expr_is
Browse files Browse the repository at this point in the history
  • Loading branch information
dinfuehr committed Jan 25, 2025
1 parent 8a65f8d commit 2068641
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
2 changes: 2 additions & 0 deletions dora-frontend/src/generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1243,6 +1243,8 @@ impl<'a> AstBytecodeGen<'a> {
self.builder.bind_label(merge_lbl);
self.pop_scope();

self.free_if_temp(value_reg);

dest
}

Expand Down
26 changes: 26 additions & 0 deletions tests/trait/trait-object3.dora
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
use std::traits::Iterator;

class Range {
value: Int
}

impl Iterator for Range {
type Item = Int;

fn next(): Option[Int] {
if self.value <= 0 {
None[Int]
} else {
let result = self.value;
self.value -= 1;
Some[Int](result)
}
}
}

fn main() {
let r = Range(2);
assert(r.next() is Some(x) && x == 2);
assert(r.next() is Some(x) && x == 1);
assert(r.next() is None);
}

0 comments on commit 2068641

Please sign in to comment.