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 return slices from an if expression #2536

Closed
0xrishabh opened this issue Sep 2, 2023 · 4 comments · Fixed by #2446
Closed

Cannot return slices from an if expression #2536

0xrishabh opened this issue Sep 2, 2023 · 4 comments · Fixed by #2446
Assignees
Labels
bug Something isn't working

Comments

@0xrishabh
Copy link

Aim

global DEPTH: Field = 11;
fn main(x: [u8; DEPTH], y: u8) {
    clear(x, y);
}
fn clear<N>(x: [u8; DEPTH], y: u8) -> [u8]{ 
    let mut new_x: [u8] = [0];
    for i in 0..x.len(){
        let b: u8 = i as u8;
        if b >= y {
            new_x[i] = x[i];
        }
        
    }
    new_x
}

Expected Behavior

Should have populated the array?

Bug

image

To Reproduce

No response

Installation Method

None

Nargo Version

No response

Additional Context

No response

Would you like to submit a PR for this Issue?

Yes

Support Needs

No response

@0xrishabh 0xrishabh added the bug Something isn't working label Sep 2, 2023
@github-project-automation github-project-automation bot moved this to 📋 Backlog in Noir Sep 2, 2023
@vezenovm
Copy link
Contributor

vezenovm commented Sep 3, 2023

Could you post which version of Noir you are using? This panic should no longer be hit as it was removed in this PR (#2347) which is included in release 0.10.4.

@0xrishabh
Copy link
Author

Yeah, you are right the error is not there in 0.10.4, but I ran the same code with the new version and it gives the error below now. @vezenovm
image

@vezenovm
Copy link
Contributor

vezenovm commented Sep 5, 2023

This panic is not descriptive enough, but this should be fixed in this PR (#2446). I will run this example against it to check. The PR is currently blocked by another bug that I am working on.

@vezenovm
Copy link
Contributor

vezenovm commented Sep 5, 2023

Looks like this issue is resolved with PR #2446, this issue will be updated once that PR is merged.

@github-project-automation github-project-automation bot moved this from 📋 Backlog to ✅ Done in Noir Sep 7, 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
Development

Successfully merging a pull request may close this issue.

2 participants