program main
  enum Color
    variant Red
    variant Blue
    variant Green
  fn make_palette() -> (array Color 3)
    array Color
      enum-variant Color.Red
      enum-variant Color.Blue
      enum-variant Color.Green
  fn echo_palette(colors: (array Color 3)) -> (array Color 3)
    var colors
  fn at(colors: (array Color 3), i: i32) -> Color
    index
      var colors
      var i
  fn local_pick() -> Color
    local let colors: (array Color 3)
      call make_palette
    index
      var colors
      int 1
  fn main() -> i32
    match
      subject
        call at
          call make_palette
          int 1
      arm Color.Blue
        int 0
      arm Color.Red
        int 1
      arm Color.Green
        int 1
  test "enum array immediate index"
    binary =
      index
        array Color
          enum-variant Color.Red
          enum-variant Color.Blue
          enum-variant Color.Green
        int 2
      enum-variant Color.Green
  test "enum array local index"
    binary =
      call local_pick
      enum-variant Color.Blue
  test "enum array param return dynamic index"
    binary =
      call at
        call echo_palette
          call make_palette
        int 0
      enum-variant Color.Red
