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

Incorrect visibility requirements on comptime functions #6485

Closed
nventuro opened this issue Nov 8, 2024 · 0 comments · Fixed by #6498
Closed

Incorrect visibility requirements on comptime functions #6485

nventuro opened this issue Nov 8, 2024 · 0 comments · Fixed by #6498
Assignees
Labels
bug Something isn't working

Comments

@nventuro
Copy link
Contributor

nventuro commented Nov 8, 2024

The following program compiles with no warnings, as expected. Note that Foo::inner is private, but this is fine because it is only used inside Foo.

mod foo {
    pub struct Foo {
        inner: Field,
    }

    impl Foo {
        pub fn new(inner: Field) -> Self {
            Self { inner }
        }
    }
}

use foo::Foo;

fn main(x: Field) -> pub Foo {
    Foo::new(x)
}

However, if we change the call to new to be comptime, we get a warning:

mod foo {
    pub struct Foo {
        inner: Field,
    }

    impl Foo {
        pub fn new(inner: Field) -> Self {
            Self { inner }
        }
    }
}

use foo::Foo;

fn main() -> pub Foo {
    comptime { Foo::new(5) }
}
warning: inner is private and not visible from the current module
   ┌─ src/main.nr:16:5
   │
16 │     comptime { Foo::new(5) }
   │     ------------------------ inner is private
   │

@nventuro nventuro added the bug Something isn't working label Nov 8, 2024
@github-project-automation github-project-automation bot moved this to 📋 Backlog in Noir Nov 8, 2024
@github-project-automation github-project-automation bot moved this from 📋 Backlog to ✅ Done in Noir Nov 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants