noname icon indicating copy to clipboard operation
noname copied to clipboard

Error reporting in programs without constraints

Open bufferhe4d opened this issue 1 year ago • 1 comments

I was writing the following example (an example where there are no constraints with a public input):

fn main(pub aa: Field) {
    let mut xx = aa + 1;
}

After running cargo run test --path examples/no_cons.no --public-inputs '{"aa": "3"}', I hit the following error:

Error:   × Looks like something went wrong in constraint-finalization
   ╭─[<BUILTIN>:1:1]
 1 │ <SEE NONAME CODE>
   · ▲
   · ╰── here
   ╰────
  help: Unexpected error: there's a bug in the circuit_writer, some cellvar does not end up being a cellvar in the circuit!.

If I try the same example with a private input, the error is more descriptive:

Error:   × Looks like something went wrong in constraint-finalization
   ╭─[examples/no_cons.no:1:1]
 1 │ fn main(aa: Field) {
   ·         ─┬
   ·          ╰── here
 2 │     let mut xx = aa + 1;
   ╰────
  help: private input not used in the circuit

I thought it could help to give the same error in those cases as help: public input not used in the circuit

bufferhe4d avatar Nov 12 '24 23:11 bufferhe4d

Yes, great discovery. I agreed it will be helpful to display where the error originate from as you said above. Feel free to create a PR if you want :)

katat avatar Nov 13 '24 02:11 katat