Skip to content

Commit

Permalink
Add Bar<Field> case to test
Browse files Browse the repository at this point in the history
  • Loading branch information
jfecher committed Feb 10, 2023
1 parent 29c82e1 commit 237308a
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions crates/nargo/tests/test_data/generics/src/main.nr
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ impl<N> BigInt<N> {
}
}

impl Bar<Field> {
fn get_other(self) -> Field {
self.other
}
}

fn main(x: Field, y: Field) {
let bar1: Bar<Field> = Bar { one: x, two: y, other: 0 };
let bar2 = Bar { one: x, two: y, other: [0] };
Expand All @@ -37,4 +43,10 @@ fn main(x: Field, y: Field) {
let int2 = BigInt { limbs: [2] };
let BigInt { limbs } = int1.second(int2).first(int1);
constrain limbs == int2.limbs;

// Test impl exclusively for Bar<Field>
constrain bar1.get_other() == bar1.other;

// Expected type error
// constrain bar2.get_other() == bar2.other;
}

0 comments on commit 237308a

Please sign in to comment.