iden3 / circom

zkSnark circuit compiler
GNU General Public License v3.0
1.33k stars 262 forks source link

Compiler panic when accessing tag for uninitialized component #149

Closed tjade273 closed 1 year ago

tjade273 commented 1 year ago
> cat test_reduced.circom
pragma circom 2.1.4;
template Test(){
    signal output {tag} out;
}

template Main() {
    component test;
    var x = test.out.tag;
}

component main = Main();

> circom test.circom
thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', type_analysis/src/analyzers/type_check.rs:678:41
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

This line should presumably be handling the case where the component has been declared but not initialized. https://github.com/iden3/circom/blob/ca3345681549c859af1f3f42128e53e3e43fe5e2/type_analysis/src/analyzers/type_check.rs#L677

clararod9 commented 1 year ago

Hi!

We have improved the error messages in our last release v2.1.5. Now the compilation of the circuit handles the case and produces the following message:

error[T20466]: Typing error found
  ┌─ "falla.circom":9:13
  │
9 │     var x = test.out.tag;
  │             ^^^^^^^^^^^^ Trying to access to a signal of a component that has not been initialized

previous errors were found

Thank you for reporting the issue :-)