Skip to content

Commit

Permalink
Add additional test for unboxing and bump version
Browse files Browse the repository at this point in the history
  • Loading branch information
titzer committed Aug 19, 2024
1 parent 87daa85 commit a0ad84a
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
2 changes: 1 addition & 1 deletion aeneas/src/main/Version.v3
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@

// Updated by VCS scripts. DO NOT EDIT.
component Version {
def version: string = "III-7.1756";
def version: string = "III-7.1757";
var buildData: string;
}
38 changes: 38 additions & 0 deletions test/variants/ub_rec07.v3
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
//@execute 0=0; 1=12; 2=44; 3=288; 5=0

type T<E> #unboxed {
case Leaf(x: E);
case One(a: T<E>.Leaf, b: T<E>.Leaf);
case Two(a: T<E>.One, b: T<E>.One);
}

def count1 = int.!<int>;
def count2 = int.+;

def main(a: int) -> int {
var x = make<int>(a, 3);
var y = make<(int, int)>(a, (4, 5));

return count(x, count1) + count(y, count2);
}

def count<E>(t: T<E>, num: E -> int) -> int {
match (t) {
Leaf(x) => return num(x);
One(a, b) => return 10 + count(a, num) + count(b, num);
Two(a, b) => return 100 + count(a, num) + count(b, num);
}
}

def make<E>(a: int, val: E) -> T<E> {
var d: T<E>;
var leaf = T<E>.Leaf(val);
var one = T<E>.One(leaf, leaf);
var two = T<E>.Two(one, one);

if (a == 1) return leaf;
if (a == 2) return one;
if (a == 3) return two;

return d;
}

0 comments on commit a0ad84a

Please sign in to comment.