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

SSA Refactor: Implement array cloning #1300

Closed
1 task
Tracked by #1376
jfecher opened this issue May 5, 2023 · 2 comments
Closed
1 task
Tracked by #1376

SSA Refactor: Implement array cloning #1300

jfecher opened this issue May 5, 2023 · 2 comments
Labels
enhancement New feature or request refactor ssa

Comments

@jfecher
Copy link
Contributor

jfecher commented May 5, 2023

Problem

In Noir, arrays are cloned when moved into another variable:

let mut a = [1, 2, 3];
let b = a;

a[0] = 5;
assert(a[0] == 5);
assert(b[0] == 1);

However the SSA refactor currently does not clone them, instead arrays function more as references:

let mut a = [1, 2, 3];
let b = a;

a[0] = 5;
// Assuming this was compiled with the new ssa refactor this would hold currently
assert(a[0] == 5);
assert(b[0] == 5);

Proposed solution

Add a check when creating new variables to clone arrays.

Alternatives considered

Alternatively, change arrays to have some immutable representation that does not need to be cloned manually. An example representation would be im::Vector which would also allow us to grow these arrays.

Additional context

No response

Submission Checklist

  • Once I hit submit, I will assign this issue to the Project Board with the appropriate tags.
@jfecher jfecher added the enhancement New feature or request label May 5, 2023
@github-project-automation github-project-automation bot moved this to 📋 Backlog in Noir May 5, 2023
@Savio-Sou
Copy link
Collaborator

@jfecher is this still relevant?

@jfecher
Copy link
Contributor Author

jfecher commented Oct 31, 2023

Alternatively, change arrays to have some immutable representation that does not need to be cloned manually. An example representation would be im::Vector which would also allow us to grow these arrays.

This is done now, we use im::Vector for all arrays in SSA.

@jfecher jfecher closed this as completed Oct 31, 2023
@github-project-automation github-project-automation bot moved this from 📋 Backlog to ✅ Done in Noir Oct 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request refactor ssa
Projects
Archived in project
Development

No branches or pull requests

3 participants