In the context of Quantum Mechanics and Hilbert spaces, I understand that a function can be interpreted as $\psi(x) = \langle x \vert \psi \rangle$ in the position basis, and things like $$\int_a^b|\psi(x)|^2dx$$make sense interpreting $x$ as a label. But if I think of $\psi(x)$ as an element of $L^2$ and expand $\psi(x)$ in a discrete basis, like $\psi(x)=\sum_a(\phi_a(x),\psi(x))\phi_a(x)$, now the label is $a$ and what does $x$ means now and why the inner product is still the same and does not make any reference to $a$?