program main
  enum Color
    variant Red
    variant Blue
    variant Green
  struct Pixel
    field x: i32
    field label: string
    field color: Color
  fn make_pixels(head: string) -> (array Pixel 3)
    array : (array Pixel 3)
      construct Pixel : Pixel
        field x
          int 1 : i32
        field label
          var head : string
        field color
          enum-variant Color.Red #0 : Color
      construct Pixel : Pixel
        field x
          int 2 : i32
        field label
          string "mid" : string
        field color
          enum-variant Color.Blue #1 : Color
      construct Pixel : Pixel
        field x
          int 3 : i32
        field label
          string "tail" : string
        field color
          enum-variant Color.Green #2 : Color
  fn echo_pixels(pixels: (array Pixel 3)) -> (array Pixel 3)
    var pixels : (array Pixel 3)
  fn at(pixels: (array Pixel 3), i: i32) -> Pixel
    index : Pixel
      var pixels : (array Pixel 3)
      var i : i32
  fn first_label(head: string) -> string
    field-access label : string
      call at : Pixel
        call make_pixels : (array Pixel 3)
          var head : string
        int 0 : i32
  fn last_color(head: string) -> Color
    field-access color : Color
      index : Pixel
        call echo_pixels : (array Pixel 3)
          call make_pixels : (array Pixel 3)
            var head : string
        int 2 : i32
  fn main() -> i32
    match : i32
      subject
        call last_color : Color
          string "head" : string
      arm Color.Green
        int 0 : i32
      arm Color.Red
        int 1 : i32
      arm Color.Blue
        int 1 : i32
  test "struct array string field access"
    binary = : bool
      call first_label : string
        string "head" : string
      string "head" : string
  test "struct array nested enum field access"
    binary = : bool
      call last_color : Color
        string "head" : string
      enum-variant Color.Green #2 : Color
  test "struct array local param return call flow"
    binary = : bool
      field-access x : i32
        call at : Pixel
          call echo_pixels : (array Pixel 3)
            call make_pixels : (array Pixel 3)
              string "sun" : string
          int 1 : i32
      int 2 : i32
