program main
  struct ArrayRecord
    field ints: (array i32 3)
    field wides: (array i64 2)
    field ratios: (array f64 3)
    field flags: (array bool 3)
    field words: (array string 3)
  fn make_record(base: i32, head: string) -> ArrayRecord
    construct ArrayRecord
      field ints
        array i32
          var base
          binary +
            var base
            int 1
          binary +
            var base
            int 2
      field wides
        array i64
          i64 40
          i64 41
      field ratios
        array f64
          float 1.5
          float 2.5
          float 3.5
      field flags
        array bool
          bool false
          bool true
          bool true
      field words
        array string
          var head
          string "moon"
          string "star"
  fn echo_record(record: ArrayRecord) -> ArrayRecord
    var record
  fn local_record(head: string) -> ArrayRecord
    local let record: ArrayRecord
      call make_record
        int 7
        var head
    call echo_record
      var record
  fn int_at(record: ArrayRecord, i: i32) -> i32
    index
      field-access ints
        var record
      var i
  fn wide_at(record: ArrayRecord, i: i32) -> i64
    index
      field-access wides
        var record
      var i
  fn ratio_at(record: ArrayRecord, i: i32) -> f64
    index
      field-access ratios
        var record
      var i
  fn flag_at(record: ArrayRecord, i: i32) -> bool
    index
      field-access flags
        var record
      var i
  fn word_at(record: ArrayRecord, i: i32) -> string
    index
      field-access words
        var record
      var i
  fn main() -> i32
    if
      call flag_at
        call local_record
          string "sun"
        int 2
      int 0
      int 1
  test "struct array i32 field access"
    binary =
      call int_at
        call make_record
          int 7
          string "sun"
        int 2
      int 9
  test "struct array i64 field access"
    binary =
      call wide_at
        call make_record
          int 7
          string "sun"
        int 1
      i64 41
  test "struct array f64 field access"
    binary =
      call ratio_at
        call make_record
          int 7
          string "sun"
        int 2
      float 3.5
  test "struct array bool field access"
    call flag_at
      call make_record
        int 7
        string "sun"
      int 1
  test "struct array string field access"
    binary =
      call word_at
        call make_record
          int 7
          string "sun"
        int 1
      string "moon"
  test "struct array local param return call flow"
    binary =
      call word_at
        call local_record
          string "sun"
        int 0
      string "sun"
