The following circuit results in an index out of bounds panic in circom:
pragma circom 2.2.3;
template Nop {
signal output out;
}
template Demo {
signal hash_bin;
if (0 == 0) {
signal foo <== 1;
hash_bin <== Nop()();
}
signal foo <== 2;
}
component main = Demo();
Command: circom circuits/circom_bug.circom -o /tmp --O1
thread 'main' panicked at constraint_list/src/constraint_simplification.rs:82:45:
index out of bounds: the len is 4 but the index is 4
stack backtrace:
0: rust_begin_unwind
1: core::panicking::panic_fmt
2: core::panicking::panic_bounds_check
3: constraint_list::constraint_simplification::build_clusters
4: constraint_list::constraint_simplification::simplification
5: constraint_list::Simplifier::simplify_constraints
6: dag::map_to_constraint_list::map
7: dag::DAG::map_to_list
8: constraint_generation::build_circuit
9: circom::execution_user::execute_project
10: circom::main
Changing any of the following makes it compile:
- Rename either of the
foo signals
- Remove the Nop template
- Remove the out signal (and the assignment to hash_bin).
- Make the condition false
- Disable optimizations (--O0)
The following circuit results in an index out of bounds panic in circom:
Command: circom circuits/circom_bug.circom -o /tmp --O1
thread 'main' panicked at constraint_list/src/constraint_simplification.rs:82:45:
index out of bounds: the len is 4 but the index is 4
stack backtrace:
0: rust_begin_unwind
1: core::panicking::panic_fmt
2: core::panicking::panic_bounds_check
3: constraint_list::constraint_simplification::build_clusters
4: constraint_list::constraint_simplification::simplification
5: constraint_list::Simplifier::simplify_constraints
6: dag::map_to_constraint_list::map
7: dag::DAG::map_to_list
8: constraint_generation::build_circuit
9: circom::execution_user::execute_project
10: circom::main
Changing any of the following makes it compile:
foosignals