zksecurity / noname

Noname: a programming language to write zkapps
https://zksecurity.github.io/noname/
179 stars 46 forks source link

Function name in use check #125

Closed MohamedElqdusy closed 3 months ago

MohamedElqdusy commented 3 months ago

Fix https://github.com/zksecurity/noname/issues/93

for the following example

use std::crypto;

fn double(xxx: Field) -> Field {
    return xxx + xxx;
} 

fn main(pub public_input: Field, private_input: Field) {
    let double = private_input;
    assert_eq(double, double(private_input));
}

the compiler should return

Error:   × Looks like something went wrong in type-checker
   ╭─[../../examples/example.no:2:1]
 2 │ 
 3 │ fn double(xxx: Field) -> Field {
   ·       ─┬─
   ·          ╰── here
 4 │     return xxx + xxx;
   ╰────
  help: function name `double` is already in use by a variable present in the scope

I updated the test after reflecting the new checks work by making the pipeline fail at https://github.com/zksecurity/noname/actions/runs/9528372535/job/26265972691?pr=125#step:6:324