DFT and perfect reconstruction of a square wave on a digital computer
First of all, it's a misunderstanding that the Gibbs phenomenon disappears if you use infinitely many Fourier series coefficients to reconstruct a discontinuous periodic function, such as a square wave. It doesn't. The reason is that generally the Fourier series doesn't converge point-wise, but it converges in the mean, i.e.,
$$\lim_{N\to\infty}\int_{0}^{T}\left|x(t)-\sum_{k=-N}^{N}c_ke^{j2\pi kt/T}\right|^2= 0\tag{1}$$
if $x(t)$ is a $T$-periodic function, and $c_k$ are its Fourier coefficients.
Taking the discrete Fourier transform (DFT) of a finite sequence of numbers just corresponds to a matrix multiplication:
$$\mathbf{y}=\mathbf{Ax}\tag{2}$$
and as long as the matrix $\mathbf{A}$ is invertible you can compute $\mathbf{x}$ from $\mathbf{y}$:
$$\mathbf{x}=\mathbf{A}^{-1}\mathbf{y}\tag{3}$$
This has nothing to do with the Fourier series of a continuous periodic function, and it has nothing to do with the Gibbs phenomenon.