A question regarding a proof in Ahlfors Ahlfors says the following: if $f (z) $ is analytic on a disc, then its integral along any closed path contained in the disc is $0$. The proof for this is the following: Let $F (z)=\int_\sigma  {f (z)dz}$ where $\sigma$ is a rectangular path that starts at a fixed point $z_0$ (they say in the middle of the disc),  and ends at $z$. Rectangular path in the sense that if we have a path from $(x_0, y_0) to (x, y)$, then we move from $(x_0, y_0)\to (x, y_0)\to (x, y)$, or $(x_0, y_0)\to (x_0, y)\to (x, y)$. So anyway, we have $F (z)= \int {f (z)dx+if (z)dy}$. Moving along the first rectangular path and differentiating wrt y, we get $dF/dy=if (z)$. Similarly, moving along the second path, we get $dF (z)/dx =f (z)$. This shows that $F (z)$ is analytic. We also have the fact that $\int {f (z) dz} $ is an exact differential, and hence dependant only on its end points. This proves that the integral on any closed path will be $0$. 
My question is that this proof works for any function $f (x, y)$ integrable on all rectangular paths, and in any open set (not just a disc). So what role does the analyticity of $f (z)$ and the shape of the disc have to play in this proof? 
 A: This proof relies on a previous theorem:

Let $f$ be a function analytic in a region containing a rectangle $R$. Then $$\int_{\partial R} f(z) \mathrm d z = 0.$$

And its proof heavily uses the analyticity of $f$ to bound something.
An open disc is open and connected so any two points can be joined by a polygonal path with segments parallel to the axis. That's how the shape plays.
A: There seems to be an important part missing from this proof, which is that the integral along both rectangular paths is equal. So that: 
$$(1) \qquad \qquad \int_{x_0}^x f(t,y_0)\, dt + \int_{y_0}^y if(x,t)\, dt = \int_{y_0}^y if(x_0,t)\, dt + \int_{x_0}^x f(t,y)\, dt$$
Otherwise $F(z)$ is not well-defined. To prove that, I would consider the sequence of paths in which you go up a little bit, then across, then up the rest of the way. That would be the integral (depending on a parameter $y_0 \leq \alpha \leq y$):
$$I(\alpha) = \int_{y_0}^{\alpha}if(x_0,t)\, dt + \int_{x_0}^x f(t,\alpha)\, dt + \int_{\alpha}^{y} if(x,t)\, dt$$
Now we have $I(y_0)$ is the LHS of (1), and $I(y)$ is the RHS. Now:
$$I'(\alpha) = if(x_0,\alpha) + \int_{x_0}^x f_y(t,\alpha)\, dt - if(x,\alpha) = \int_{x_0}^x if_x(t,\alpha)\, dt - \left[if(x,\alpha) - if(x_0,\alpha)\right] = 0$$
Here we have explicitly used the analyticity of $f$: $f_y = if_x$. This implies $F$ is well-defined.
Now what about the region? In order for this proof to work, we need the entire rectangle between $(x_0,y_0)$ and $(x,y)$ to be contained in the region. So other regions besides a disc work, but there are problems if the region has any 'holes'. The fancy term is 'simply connected'.
For instance, take the region $\mathbb{C} \backslash \{0\}$. The function $f(z) = 1/z$ is analytic on this region, but integrating in a circular path around 0 gives a nonzero number.
