-- in.cue --
intIndex: [2][0]
stringIndex: {foo: "bar"}["foo"]

stringOfNumberIndex: {"3": 3}["3"]

indexToDefault: (*[0] | {})[0]
outOfBoundsDisjunction: (*[] | {})[1]

// Ensure these are errors.
indexDoesNotDistribute: (*[] | [1])[0]
doesNotDistributeType: {
	l: []
	a: (*l | {"3": 3})["3"]
}

stringIndexToList: [2][""]
indexOutOfBounds2: 2[2]
booleanIndex: [][true]
indexOutOfBounds3: [1, 2, 3][4]
negativeIndex: [1, 2, 3][-1]

varIndexTooLarge: {
	n: 3
	a: [1, 2, 3][n]
}

varNegativeIndex: {
	n: -1
	a: [1, 2, 3][n]
}
-- out/compile --
--- in.cue
{
  intIndex: [
    2,
  ][0]
  stringIndex: {
    foo: "bar"
  }["foo"]
  stringOfNumberIndex: {
    "3": 3
  }["3"]
  indexToDefault: (*[
    0,
  ]|{})[0]
  outOfBoundsDisjunction: (*[]|{})[1]
  indexDoesNotDistribute: (*[]|[
    1,
  ])[0]
  doesNotDistributeType: {
    l: []
    a: (*〈0;l〉|{
      "3": 3
    })["3"]
  }
  stringIndexToList: [
    2,
  ][""]
  indexOutOfBounds2: 2[2]
  booleanIndex: [][true]
  indexOutOfBounds3: [
    1,
    2,
    3,
  ][4]
  negativeIndex: [
    1,
    2,
    3,
  ][-1]
  varIndexTooLarge: {
    n: 3
    a: [
      1,
      2,
      3,
    ][〈0;n〉]
  }
  varNegativeIndex: {
    n: -1
    a: [
      1,
      2,
      3,
    ][〈0;n〉]
  }
}
