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

Add support for nested arrays on unconstrained functions #2028

Closed
sirasistant opened this issue Jul 25, 2023 · 0 comments · Fixed by #2029
Closed

Add support for nested arrays on unconstrained functions #2028

sirasistant opened this issue Jul 25, 2023 · 0 comments · Fixed by #2029
Labels
enhancement New feature or request

Comments

@sirasistant
Copy link
Contributor

Problem

Now that AOS2SOA has been removed, we need to support nested arrays in brillig to support arrays of structs that hold arrays inside them.

Happy Case

The following should compile:

struct Header {
    params: [Field; 3],
}

struct MyNote {
    plain: Field,
    array: [Field; 2],
    header: Header,
}

unconstrained fn access_nested(notes: [MyNote; 2], x: Field, y: Field) -> Field {
    notes[x].array[y] + notes[y].array[x] + notes[x].plain + notes[y].header.params[x]
}

unconstrained fn create_inside_brillig(x: Field, y: Field) {
    let header = Header { params: [1, 2, 3]};
    let note0 = MyNote { array: [1, 2], plain : 3, header };
    let note1 = MyNote { array: [4, 5], plain : 6, header };
    assert(access_nested([note0, note1], x, y) == (2 + 4 + 3 + 1));
}

fn main(x: Field, y: Field) {
    let header = Header { params: [1, 2, 3]};
    let note0 = MyNote { array: [1, 2], plain : 3, header };
    let note1 = MyNote { array: [4, 5], plain : 6, header };

    create_inside_brillig(x, y);
    assert(access_nested([note0, note1], x, y) == (2 + 4 + 3 + 1));
}

Alternatives Considered

No response

Additional Context

No response

Would you like to submit a PR for this Issue?

Yes

Support Needs

No response

@sirasistant sirasistant added the enhancement New feature or request label Jul 25, 2023
@github-project-automation github-project-automation bot moved this to 📋 Backlog in Noir Jul 25, 2023
@github-project-automation github-project-automation bot moved this from 📋 Backlog to ✅ Done in Noir Jul 25, 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
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

1 participant