$1/z^2$ and Morera's theorem - contradiction?

Consider a complex function $f(z)=\frac{1}{z^2}$. We know it has a singularity at $z_0=0$ and that it's holomorphic elsewhere. Then we know by Cauchy's integral theorem that $\int_\gamma \frac{1}{z^2}\mathrm{d}z=0$ for every appropriate closed curve $\gamma$, such that its interior doesn't contain $0$. When $\gamma$ interior contains $0$ we can show that $\forall \gamma \,\,\exists r$, such that $$\int_{\gamma}f(z)\mathrm{d}z=\int_{|z|=r}f(z)\mathrm{d}z\,,$$ provided that the whole circle bounded by $|z|=r$ lays inside the interior of $\gamma$. Let now compute $$\int_{|z|=r}\frac{1}{z^2}\mathrm{d}z=\int_0^{2\pi}\frac{ire^{i\varphi}}{r^2e^{2i\varphi}}\mathrm{d}{\varphi}=C\int_0^{2\pi}e^{-i\varphi}\mathrm{d}\varphi = 0.$$
The above shows that for arbitrary chosen regular curve $\gamma$ the contour integral is always equal to $0$. As the function $f(z)$ suffices assumptions we can apply Morera's theorem, which implies $f(z)$ is holomorphic on $\mathbb{C}$. That's a contradiction.

What's more same thing occurs for $g_k(z)=z^k$ for all $z\in\mathbb{Z}$ except for $k=-1$. That is also a crucial property when trying to prove Cauchy integral formula and Residue thoerem. It's equivalent to integral of Laurent series depending only on the $-1$st coefficient.

There's obviously some flaw in my understadning of the matter, wich I don't seem to notice. Hence my question arises. I will much appreciate any clue.

• No. You cannot take curves that pass through zero, hence you cannot use Morera's theorem. – uniquesolution Jun 26 '17 at 10:42
• Morera's theorem assumes $f$ is continuous – mercio Jun 26 '17 at 10:42
• That in fact clears it up, thanks. However I don't quite get mercio's comment. $1/z^2$ is conituous on its domain. It just can't be defined at $0$, thus we're not allowed to consider regions containing $0$ when trying to apply Morera's theorem - that's where my mistake has laid. – piwox Jun 26 '17 at 11:15

Morera's theorem is applicable on $\Omega = \mathbb{C} \setminus \{ 0 \}$ where $f$ is indeed holomorphic.
It is, however, not applicable on $\Omega = \mathbb{C}$ where $f$ isn't even defined, let alone continuous.