iden3 / circom

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

Invalid syntax causes crash rather than error message #195

Closed tim-hoffman closed 11 months ago

tim-hoffman commented 1 year ago

Commit: 878d6754720560e42dc8f5831f47f7d7d7fa99ea

Input (invalid.circom):

pragma circom 2.0.0;

function funA(){
    var out[1];
    /*return*/ out;
}

template TempA() {
    var result[1] = funA();
}

component main = TempA();

Command:

cargo build --release
target/release/circom invalid.circom

Outcome:

thread 'main' panicked at 'internal error: entered unreachable code', type_analysis/src/analyzers/symbol_analysis.rs:167:47
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Relevant line: https://github.com/iden3/circom/blob/878d6754720560e42dc8f5831f47f7d7d7fa99ea/type_analysis/src/analyzers/symbol_analysis.rs#L167C27-L167C27

clararod9 commented 11 months ago

Hi! We have solved this issue in our last commits, now the compilation of the circuit returns the following error message:

error[P1012]: illegal expression
  ┌─ "aux.circom":5:19
  │
5 │     /*return*/ out;
  │                   ^ here

previous errors were found

Thank you for reporting the issue