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

Infer an array literal to be a slice when an array of different length is assigned #2370

Closed
jfecher opened this issue Aug 18, 2023 · 0 comments · Fixed by #3225
Closed

Infer an array literal to be a slice when an array of different length is assigned #2370

jfecher opened this issue Aug 18, 2023 · 0 comments · Fixed by #3225
Assignees
Labels
compiler frontend `noirc_frontend` crate enhancement New feature or request

Comments

@jfecher
Copy link
Contributor

jfecher commented Aug 18, 2023

Problem

The compiler currently disallows the code:

let mut slice = [];
slice = [1, 2, 3];

When it could be perfectly valid if we assume slice: [Field] rather than slice: [Field; 0] as the compiler currently infers.

Happy Case

Allow Type::Array(T, MaybeConstant(N)) to unify with Type::Array(T, MaybeConstant(M)) if N != M to Type::Array(T, NotConstant) ie. a slice type.

Alternatives Considered

No response

Additional Context

No response

Would you like to submit a PR for this Issue?

No

Support Needs

No response

@jfecher jfecher added enhancement New feature or request P-LOW labels Aug 18, 2023
@jfecher jfecher self-assigned this Aug 18, 2023
@github-project-automation github-project-automation bot moved this to 📋 Backlog in Noir Aug 18, 2023
@jfecher jfecher added the compiler frontend `noirc_frontend` crate label Aug 18, 2023
@github-project-automation github-project-automation bot moved this from 📋 Backlog to ✅ Done in Noir Oct 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler frontend `noirc_frontend` crate enhancement New feature or request
Projects
Archived in project
1 participant