noir-lang / noir

Noir is a domain specific language for zero knowledge proofs
https://noir-lang.org
Apache License 2.0
875 stars 189 forks source link

Warn on items more private than others #6248

Open asterite opened 6 days ago

asterite commented 6 days ago

Problem

For example in this Rust code:

struct Foo {}

pub fn bar() -> Foo {
    Foo {}
}

Rust says that Foo is more private than bar.

We should do the same in Noir and also in similar cases (for example when defining a struct with fields that are more visible than the struct).

Happy Case

Noir warns/errors in the above snippet and similar ones.

Workaround

None

Workaround Description

No response

Additional Context

No response

Project Impact

None

Blocker Context

No response

Would you like to submit a PR for this Issue?

None

Support Needs

No response

TomAFrench commented 4 days ago

@asterite have you started on this? I'm thinking this could be a good issue for @aakoshh

asterite commented 4 days ago

No, I didn't start yet, so feel free to assign it to Akosh :-)

aakoshh commented 3 days ago

Tests can go into compiler/noirc_frontend/src/tests/visibility.rs Look at Elaborator::elaborate_function for example