Skip to content

Support var.len #258

@katat

Description

@katat

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);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions