#include <metal_stdlib>
using namespace metal;
template<typename T, size_t N>
struct tint_array {
  const constant T& operator[](size_t i) const constant { return elements[i]; }
  device T& operator[](size_t i) device { return elements[i]; }
  const device T& operator[](size_t i) const device { return elements[i]; }
  thread T& operator[](size_t i) thread { return elements[i]; }
  const thread T& operator[](size_t i) const thread { return elements[i]; }
  threadgroup T& operator[](size_t i) threadgroup { return elements[i]; }
  const threadgroup T& operator[](size_t i) const threadgroup { return elements[i]; }
  T elements[N];
};


float f1(tint_array<float, 4> a) {
  return a[3];
}
float f2(tint_array<tint_array<float, 4>, 3> a) {
  return a[2][3];
}
float f3(tint_array<tint_array<tint_array<float, 4>, 3>, 2> a) {
  return a[1][2][3];
}
kernel void tint_symbol() {
  tint_array<float, 4> const a1 = tint_array<float, 4>{};
  tint_array<tint_array<float, 4>, 3> const a2 = tint_array<tint_array<float, 4>, 3>{};
  tint_array<tint_array<tint_array<float, 4>, 3>, 2> const a3 = tint_array<tint_array<tint_array<float, 4>, 3>, 2>{};
  float const v1 = f1(a1);
  float const v2 = f2(a2);
  float const v3 = f3(a3);
}
