line integral on a closed curve I'm reading Conway's complex analysis book and I'm trying to solve the integral $\int_{\gamma}f$, where $f(z)=|z|^2$ and the curve $\gamma$ is the closed polygon $[1,1+i,i,0,1]$. 
I didn't understand why I didn't find zero as a solution of this integral.
See the theorem which supports my thinking (page 66):

Theorem: Let $G$ be  an open set in $\mathbb C$, $\gamma:[a,b]\to G$ is a rectifiable path, and $f:G\to \mathbb C$ a continuous function, and has a primitive $F$.
  If $\gamma$ is a closed curve then $$\int_{\gamma}f=0$$

 A: As others have told you the function $f(z):=z\>\bar z$ is a nice function in the plane, but not a holomorphic function. Therefore Cauchy's theorem does not apply, and we have to compute the quantity $Q$ in question "the hard way". The following trick helps in this example (and in similar examples where $\gamma$ is a circle):
Let $\gamma=\sum_{k=1}^4\gamma_k$ where $\gamma_k$ are the four segment parts of $\gamma$, starting with $\gamma_1$ going from $0$ to $1$. On $\gamma_1$ one has $\bar z=z$, on $\gamma_2$ one has $\bar z=-z+2$, on $\gamma_3$ one has $\bar z=z-2i$, and on $\gamma_4$ one has $\bar z=-z$. It follows that
$$Q:=\int_\gamma z\>\bar z\>dz=\int_0^1 z^2\>dz+\int_1^{1+i}z(-z+2)\>dz+\int_{1+i}^i z(z-2i)\>dz+\int_i^0 z(-z)\>dz\ .$$
Now in each integral the integrand is a holomorphic function. Therefore we are allowed to write
$$Q=\left({1\over3}z^3\right)\biggr|_0^1+ \left(-{1\over3}z^3+z^2\right)\biggr|_1^{1+i} +
\left({1\over3}z^3-iz^2\right)\biggr|_{1+i}^i+ \left(-{1\over3}z^3\right)\biggr|_i^0\ . $$
A: You can simplify the integral a little by writing $|z|^2= z^2 -2xyi$, using the fact that $z^2$ is holomorphic together with the theorem you cited. Then apply Fubini.
