noir-lang / noir

Noir is a domain specific language for zero knowledge proofs
https://noir-lang.org
Apache License 2.0
884 stars 195 forks source link

"The bit count in a bit-shift operation must fit in a u8, try casting the right hand side into a u8 first" on a u8 value #5823

Closed sirasistant closed 2 months ago

sirasistant commented 2 months ago

Aim

Compile https://github.com/noir-lang/noir-bignum with latest noir

Expected Behavior

It should compile

Bug

error: The bit count in a bit-shift operation must fit in a u8, try casting the right hand side into a u8 first
    ┌─ src/utils/u60_representation.nr:198:46
    │
198 │         result.limbs.set(num_shifted_limbs, (value << limb_shift) & mask);
    │                                              -------------------
    │

error: The bit count in a bit-shift operation must fit in a u8, try casting the right hand side into a u8 first
    ┌─ src/utils/u60_representation.nr:204:29
    │
204 │             let upshift = ((value << limb_shift) + remainder) & mask;
    │                             -------------------
    │

But limb_shift is a u8 defined as let limb_shift = (shift % 60) as u8;

To Reproduce

1. 2. 3. 4.

Workaround

Yes

Workaround Description

Manually cast to u8 in the callsite

Additional Context

No response

Project Impact

None

Blocker Context

No response

Nargo Version

No response

NoirJS Version

No response

Proving Backend Tooling & Version

No response

Would you like to submit a PR for this Issue?

None

Support Needs

No response

jfecher commented 2 months ago

This crate compiles and tests pass for me on

nargo version = 0.33.0
noirc version = 0.33.0+3e13b34a653ce5ce0894cf74b845399b4628bd05

Edit: I see you've updated the repo to workaround this. I'll undo it and try again.