diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 30c4a96..16b3e08 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -12,7 +12,7 @@ jobs: with: toolchain: stable - name: Cache target - uses: actions/cache@v2 + uses: actions/cache@v4 env: cache-name: cache-default-target-and-lockfile with: diff --git a/src/circuit.rs b/src/circuit.rs index 5e35f81..56b98a9 100644 --- a/src/circuit.rs +++ b/src/circuit.rs @@ -1241,7 +1241,7 @@ impl CircuitBuilder { fn unsigned_as_usize_bits(n: u64) -> [usize; USIZE_BITS] { let mut bits = [0; USIZE_BITS]; for (i, bit) in bits.iter_mut().enumerate().take(USIZE_BITS) { - *bit = (n >> (USIZE_BITS - 1 - i) & 1) as usize; + *bit = ((n >> (USIZE_BITS - 1 - i)) & 1) as usize; } bits } diff --git a/src/compile.rs b/src/compile.rs index 9b62985..922f541 100644 --- a/src/compile.rs +++ b/src/compile.rs @@ -1386,13 +1386,13 @@ pub(crate) fn enum_max_size( pub(crate) fn unsigned_to_bits(n: u64, size: usize, bits: &mut Vec) { for i in 0..size { - bits.push((n >> (size - 1 - i) & 1) == 1); + bits.push(((n >> (size - 1 - i)) & 1) == 1); } } pub(crate) fn signed_to_bits(n: i64, size: usize, bits: &mut Vec) { for i in 0..size { - bits.push((n >> (size - 1 - i) & 1) == 1); + bits.push(((n >> (size - 1 - i)) & 1) == 1); } } diff --git a/tests/compile.rs b/tests/compile.rs index e7418fd..cfd76f8 100644 --- a/tests/compile.rs +++ b/tests/compile.rs @@ -430,7 +430,7 @@ pub fn main(x: i16, y: i16) -> bool { for x in -10..10 { for y in -10..10 { let mut eval = compiled.evaluator(); - let expected = (x > y) && (y < x); + let expected = x > y; eval.set_i16(x); eval.set_i16(y); let output = eval.run().map_err(|e| pretty_print(e, prg))?; @@ -1840,7 +1840,7 @@ pub fn main(a: bool, b: bool, c: bool) -> bool { (a & b) | (a & c) } "; - let compiled = compile(&prg).map_err(|e| pretty_print(e, &prg))?; + let compiled = compile(prg).map_err(|e| pretty_print(e, prg))?; for a in [true, false] { for b in [true, false] { for c in [true, false] { @@ -1848,9 +1848,9 @@ pub fn main(a: bool, b: bool, c: bool) -> bool { eval.set_bool(a); eval.set_bool(b); eval.set_bool(c); - let output = eval.run().map_err(|e| pretty_print(e, &prg))?; + let output = eval.run().map_err(|e| pretty_print(e, prg))?; assert_eq!( - bool::try_from(output).map_err(|e| pretty_print(e, &prg))?, + bool::try_from(output).map_err(|e| pretty_print(e, prg))?, (a & b) | (a & c), "({a} & {b}) | ({a} & {c})" );