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

Unconstrained print of mutable array panics #7275

Open
michaeljklein opened this issue Feb 4, 2025 · 0 comments
Open

Unconstrained print of mutable array panics #7275

michaeljklein opened this issue Feb 4, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@michaeljklein
Copy link
Contributor

michaeljklein commented Feb 4, 2025

Aim

Attempted to debug an unconstrained function by printing an intermediate mutable-array value:

unconstrained fn foo(arr: &mut [Field; 0]) {
    println(arr);
}

unconstrained fn main() {
    let mut arr = [0; 0];
    foo(&mut arr);
}

Note that this may be related to #7274, but will require distinct regression testing because the panic occurs in a different location.

Expected Behavior

Expected the array to be printed successfully or else fail with a user error.

Bug

nargo execute panics:

The application panicked (crashed).
Message:  internal error: entered unreachable code: println and format strings do not support mutable references.
Location: compiler/noirc_frontend/src/monomorphization/mod.rs:1593

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

To Reproduce

Workaround

Yes

Workaround Description

Make a copy of the array before printing:

let arr_copy: [Field; _] = *arr;
println(arr_copy);

Additional Context

No response

Project Impact

Nice-to-have

Blocker Context

No response

Nargo Version

nargo version = 1.0.0-beta.1 noirc version = 1.0.0-beta.1+130d99125a09110a3ee3e877d88d83b5aa37f369 (git version hash: 130d991, is dirty: false)

NoirJS Version

No response

Proving Backend Tooling & Version

No response

Would you like to submit a PR for this Issue?

None

Support Needs

No response

@michaeljklein michaeljklein added the bug Something isn't working label Feb 4, 2025
@github-project-automation github-project-automation bot moved this to 📋 Backlog in Noir Feb 4, 2025
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
Status: 📋 Backlog
Development

No branches or pull requests

1 participant