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

Support var.len #258

Open
katat opened this issue Jan 4, 2025 · 1 comment
Open

Support var.len #258

katat opened this issue Jan 4, 2025 · 1 comment
Labels

Comments

@katat
Copy link
Collaborator

katat commented Jan 4, 2025

It will be handy to directly obtain the length of an array variable.

For example

fn init_arr(const LEN: Field) -> [Field; LEN + 2] {
 return [0; LEN + 2];
}

fn main() {
  let arr = init_arr(10);
  assert_eq(arr.len, 12);

  // should also support being used to instantiate functions in mast phase
  let arr2 = init_arr(arr.len);
  assert_eq(arr2.len, 14);
}
@katat katat added the easy label Jan 4, 2025
@cyberbono3
Copy link

let me take it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants