I'm uncertain about the subtleties of the following contour integration, so maybe somebody can tell me what is precisely going on.
First consider the function $$ f(z)=\sum_{n=0}^\infty z^n = \frac{1}{1-z} \qquad |z|<1 \tag{1} $$ which converges for $|z|<1$. As far as I'm aware it even converges for $|z|=1$ as long as $z\neq 1$. Now integrate over the circle of radius $R<1$ $$ \oint_{|z|=R} f(z) \, {\rm d}z \, . $$ The pole of the RHS of ${\rm (1)}$ is not enclosed, and thus the integral is zero. Indeed the LHS gives $$ \oint_{|z|=R} \sum_{n=0}^\infty z^n \, {\rm d}z \stackrel{R<1}{=} \sum_{n=0}^\infty \oint_{|z|=R} z^{n} \, {\rm d}z $$ but $$ \oint_{|z|=R} z^{n} \, {\rm d}z = 2\pi i \, R^{n+1} \, \delta_{n,-1} \tag{2} $$ so every term of the series is zero as expected. Now what does happen if $R=1$ ? Is everything still allowed as long as I miss the pole at $z=1$ by $\epsilon>0$ (integration from $1+\epsilon$ to $1-\epsilon$) ?
I'm asking, because now consider the following function $$ g(z)=\sum_{n=-\infty}^\infty z^n \qquad |z|=1,z\neq 1 \tag{3} $$ which should converge for $|z|=1,z\neq 1$. If I would like to assign some function to the RHS of ${\rm (3)}$ it would be something like $2\pi i \, \delta(z-1)$. Again integration over $|z|=R$ gives $$ \oint_{|z|=R} \sum_{n=-\infty}^\infty z^n \, {\rm d}z \stackrel{?}{=} \sum_{n=-\infty}^\infty \oint_{|z|=R} z^{n} \, {\rm d}z $$ where I presume the only allowed value for interchanging the order of summation would be $R=1$. Then by ${\rm (2)}$ the term $n=-1$ is covered and yields $2\pi i$. But if $R=1$ is allowed, then why is it not possible to obtain the same result with the function $f(z)$ using the series?
If $F(z)$ is a holomorphic function, then the way I interpret this is \begin{align} \int_{a^+}^{b^+} F(z) \sum_{n=-\infty}^\infty z^n \, {\rm d}z &= \int_{a^+}^{b^+}\frac{F(z)}{1-z} \, {\rm d}z + \int_{a^-}^{b^-} \frac{F(z)}{z-1} \, {\rm d}z \\ &=\int_{b^+}^{a^+}\frac{F(z)}{z-1} \, {\rm d}z + \int_{a^-}^{b^-} \frac{F(z)}{z-1} \, {\rm d}z \\ &= \oint_{b^+}^{b^-}\frac{F(z)}{z-1} \, {\rm d}z \\ &= 2\pi i \, F(1) \end{align} with $a<1<b$.