Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warn on items more private than others #6248

Closed
asterite opened this issue Oct 8, 2024 · 3 comments · Fixed by #6296
Closed

Warn on items more private than others #6248

asterite opened this issue Oct 8, 2024 · 3 comments · Fixed by #6296
Assignees
Labels
enhancement New feature or request

Comments

@asterite
Copy link
Collaborator

asterite commented Oct 8, 2024

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

@asterite asterite added the enhancement New feature or request label Oct 8, 2024
@github-project-automation github-project-automation bot moved this to 📋 Backlog in Noir Oct 8, 2024
@TomAFrench
Copy link
Member

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

@asterite
Copy link
Collaborator Author

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

@aakoshh
Copy link
Contributor

aakoshh commented Oct 11, 2024

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

github-merge-queue bot pushed a commit that referenced this issue Oct 19, 2024
… fields (#6296)

# Description

## Problem\*

Resolves #6248

## Summary\*

Issue warnings in more cases when a public item refers to private types:
* public fields of a public struct fields using private types
* a public function taking or returning private types

## Additional Context



## Documentation\*

Check one:
- [x] No documentation needed.
- [ ] Documentation included in this PR.
- [ ] **[For Experimental Features]** Documentation to be submitted in a
separate PR.

# PR Checklist\*

- [x] I have tested the changes locally.
- [ ] I have formatted the changes with [Prettier](https://prettier.io/)
and/or `cargo fmt` on default settings.
@github-project-automation github-project-automation bot moved this from 📋 Backlog to ✅ Done in Noir Oct 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants