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

Compiler doesn't infer generics on Field::from_be_bytes correctly #6188

Closed
TomAFrench opened this issue Oct 1, 2024 · 1 comment · Fixed by #6404
Closed

Compiler doesn't infer generics on Field::from_be_bytes correctly #6188

TomAFrench opened this issue Oct 1, 2024 · 1 comment · Fixed by #6404
Assignees

Comments

@TomAFrench
Copy link
Member

#6084 added the Field::from_be_bytes and Field::from_le_bytes functions. These are generic in their inputs however the compiler doesn't seem to be able to determine the value of N from the passed array.

This is likely due to the fact that it's an impl on a primitive type, so we should check for inconsistencies between how we handle these relative to struct impls.

@github-project-automation github-project-automation bot moved this to 📋 Backlog in Noir Oct 1, 2024
@asterite
Copy link
Collaborator

asterite commented Oct 2, 2024

I thought about working on this next but this program:

fn main() {
    let bytes = [1, 2, 3];
    let field = Field::from_be_bytes(bytes);
}

crashes with the same error a recent PR tried to fix:

The application panicked (crashed).
Message:  while substituting (unbound): expected kind of unbound TypeVariable (Numeric(u32)) to match the kind of its binding (Normal)
Location: compiler/noirc_frontend/src/hir_def/types.rs:2003

so there might be other cases where Kind::Normal is used instead of Kind::Any (I wonder if Kind::Normal is the same as Kind::Any and only Any should remain).

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

Successfully merging a pull request may close this issue.

2 participants