Handle empty array in the subscript operator

Addresses #2133