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

Cannot infer type when assigning comptime generic field to a Field. #2055

Closed
iAmMichaelConnor opened this issue Jul 26, 2023 · 0 comments · Fixed by #2179
Closed

Cannot infer type when assigning comptime generic field to a Field. #2055

iAmMichaelConnor opened this issue Jul 26, 2023 · 0 comments · Fixed by #2179
Assignees
Labels
bug Something isn't working

Comments

@iAmMichaelConnor
Copy link
Collaborator

iAmMichaelConnor commented Jul 26, 2023

The following panics when the annotation : Field is omitted.

fn be_bytes_to_field<LEN>(bytes: [u8; LEN]) -> Field {
    let mut f = 0;
    let mut b = 1;
    let mut len = LEN - 1; // FAILS
    // let mut len: Field = LEN - 1; // SUCCEEDS
    for i in 0..LEN {
        let j = len - i;
        f += (bytes[j] as Field) * b;
        b *= 256;
    }
    f
}

fn main(bytes: [u8; 8]) -> pub Field {
    let f: Field = be_bytes_to_field(bytes);
    f
}

#[test]
fn test_bytes_to_field() {
    let bytes: [u8; 8] = [0, 0, 0, 0, 0, 1, 3, 1];
    let f = main(bytes);
    std::println(f);
}
Running 1 test functions...
Testing test_bytes_to_field...
The application panicked (crashed).
Message:  internal error: entered unreachable code: Unexpected type error found
Location: crates/noirc_frontend/src/monomorphization/mod.rs:736

This is a bug. We may have already fixed this in newer versions of Nargo so try searching for similar issues at https://github.com/noir-lang/noir/issues/.
If there isn't an open issue for this bug, consider opening one at https://github.com/noir-lang/noir/issues/new?labels=bug&template=bug_report.yml

Using latest Noir master, commit 4ecf3c4.

nargo test --show-output

@iAmMichaelConnor iAmMichaelConnor added the bug Something isn't working label Jul 26, 2023
@github-project-automation github-project-automation bot moved this to 📋 Backlog in Noir Jul 26, 2023
@jfecher jfecher self-assigned this Aug 2, 2023
@github-project-automation github-project-automation bot moved this from 📋 Backlog to ✅ Done in Noir Aug 8, 2023
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
2 participants