zksecurity / noname

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

Type check bugs: compiler accept when we use function name as variable. #93

Closed vuvoth closed 2 months ago

vuvoth commented 3 months ago

Context

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

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

A problem above compile success in noname.

How to fix it?

We should fix type checker.

MohamedElqdusy commented 3 months ago

@vuvoth your example is a valid Rust syntax, I think it should not compile only after double() call as the following

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

fn double(pub public_input: Field, private_input: Field) -> Field {
    return private_input + public_input;
}