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

Allow returning nested arrays from brillig to ACIR #2046

Closed
sirasistant opened this issue Jul 26, 2023 · 0 comments · Fixed by #2047
Closed

Allow returning nested arrays from brillig to ACIR #2046

sirasistant opened this issue Jul 26, 2023 · 0 comments · Fixed by #2047
Labels
acir-gen enhancement New feature or request

Comments

@sirasistant
Copy link
Contributor

Problem

Right now acir_gen assumes returned arrays from brillig are value arrays. It is handled on brillig inputs, so follow the same strategy as with brillig inputs.

Happy Case

The following should compile:

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

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

fn access_nested(notes: [MyNote; 2]) -> Field {
    notes[0].array[1] + notes[1].array[0] + notes[0].plain + notes[1].header.params[0]
}

unconstrained fn create_inside_brillig(values: [Field; 6]) -> [MyNote; 2] {
    let header = Header { params: [values[0], values[1], values[2]]};
    let note0 = MyNote { array: [values[0], values[1]], plain : values[2], header };
    let note1 = MyNote { array: [values[3], values[4]], plain : values[5], header };
    [note0, note1]
}

fn main(values: [Field; 6]) {
    let notes = create_inside_brillig(values);
    assert(access_nested(notes) == (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 26, 2023
@github-project-automation github-project-automation bot moved this to 📋 Backlog in Noir Jul 26, 2023
@github-project-automation github-project-automation bot moved this from 📋 Backlog to ✅ Done in Noir Jul 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
acir-gen enhancement New feature or request
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants