circom-witness-rs icon indicating copy to clipboard operation
circom-witness-rs copied to clipboard

index out of bounds: the len is 4 but the index is 4

Open vivianjeng opened this issue 1 year ago • 1 comments

Hi, When I build with the multiplier circuit

pragma circom 2.1.4;

/*This circuit template checks that c is the multiplication of a and b.*/  

template Multiplier2 () {  

   // Declaration of signals.  
   signal input a;  
   signal input b;  
   signal output c;  

   // Constraints.  
   c <== a * b;  
}

component main { public [ a ] } = Multiplier2();

It shows the error

error: failed to run custom build command for `wtest v0.1.0 (/Users/zhengyawen/Documents/GitHub/semaphore-witness-example)`
note: To improve backtraces for build dependencies, set the CARGO_PROFILE_DEV_BUILD_OVERRIDE_DEBUG=true environment variable to enable debug information generation.

Caused by:
  process didn't exit successfully: `/Users/zhengyawen/Documents/GitHub/semaphore-witness-example/target/debug/build/wtest-d40a5b9cdeee7289/build-script-build` (exit status: 101)
  --- stderr
  thread 'main' panicked at /Users/zhengyawen/.cargo/git/checkouts/circom-witness-rs-68138715c9db01bf/1de8315/src/generate.rs:218:22:
  index out of bounds: the len is 4 but the index is 4
  stack backtrace:
     0: rust_begin_unwind
               at /rustc/a28077b28a02b92985b3a3faecf92813155f1ea1/library/std/src/panicking.rs:597:5
     1: core::panicking::panic_fmt
               at /rustc/a28077b28a02b92985b3a3faecf92813155f1ea1/library/core/src/panicking.rs:72:14
     2: core::panicking::panic_bounds_check
               at /rustc/a28077b28a02b92985b3a3faecf92813155f1ea1/library/core/src/panicking.rs:180:5
     3: <usize as core::slice::index::SliceIndex<[T]>>::index_mut
     4: <alloc::vec::Vec<T,A> as core::ops::index::IndexMut<I>>::index_mut
     5: witness::generate::build_witness
     6: build_script_build::main
     7: core::ops::function::FnOnce::call_once
  note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

Do you have any idea about how this happened?

vivianjeng avatar Jan 30 '24 12:01 vivianjeng