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

Types on numeric generics are not respected #5886

Closed
TomAFrench opened this issue Sep 2, 2024 · 1 comment
Closed

Types on numeric generics are not respected #5886

TomAFrench opened this issue Sep 2, 2024 · 1 comment

Comments

@TomAFrench
Copy link
Member

fn main() -> pub [u8; BAZ] {
    Foo::bar()
}

struct Foo;

trait Bar<let N: u1> {
    fn bar() -> [u8; N];
}

global BAZ: Field = 8;

impl Bar<BAZ> for Foo {
    fn bar() -> [u8; BAZ] {
        [0; BAZ]
    }

}

Consider the above program. I've specified that the Bar trait has a numeric generic parameter which is of the type u1. I'm then allowed to implement this trait using a Field of value 8. This then allows me to have Foo::bar() return a [u8; 8] whereas reading the trait definition this should not be allowed.

@github-project-automation github-project-automation bot moved this to 📋 Backlog in Noir Sep 2, 2024
@vezenovm
Copy link
Contributor

vezenovm commented Sep 3, 2024

I made an issue for this here (#5447). This is easier to implement as part of #5156

@vezenovm vezenovm closed this as completed Sep 3, 2024
@github-project-automation github-project-automation bot moved this from 📋 Backlog to ✅ Done in Noir Sep 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

No branches or pull requests

2 participants