iden3 / circom

zkSnark circuit compiler
GNU General Public License v3.0
1.28k stars 244 forks source link

compiler crash with `internal error: entered unreachable code` #216

Closed bkomuves closed 7 months ago

bkomuves commented 10 months ago

The following circom program crashes the compiler:

pragma circom 2.0.0;

function foo(x) {
  var bar[1+1];       // this is the problematic line. `var bar[2];` works
  bar[0] = x;
  bar[1] = x;
  return bar;
}

template Main() {
  signal input  inp;
  signal output out;

  var baz[2] = foo(5);

  out <== inp + baz[0];
}

component main {public [inp]} = Main();

with the error message:

thread 'main' panicked at compiler/src/hir/merger.rs:652:13:
internal error: entered unreachable code
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

To reproduce, simply copy the above into a file bug.circom and run

$ circom --r1cs bug.circom

Circom version: 2.1.6, built from source on macOS with rustc 1.73.0

clararod9 commented 8 months ago

Hi!

Thank you for detecting this issue, we have solved it in the last release (circom 2.1.7).