Let $X$ be a compact Riemann surface. Suppose that $f$ is holomorphic over all of $X$. Then $f$ is constant
I proved this in the following way:
The function $f$ is continuous and hence $|f|$ attains a maximum value $M$. Let $p$ be a point of $X$ such that $|f(p)|=M$. By the Maximum Modulus Principle, $|f|$ is constant (equal to $M$) in a neighborhood of $p$. That is, the set of all $x$ that $|f(x)|=M$ is open. However such set is also closed since $f$ is continuous. Connectedness implies that $|f|$ is constant. Then $f(X)$ is contained in a circle of radius $M$. This contradicts the open mapping theorem.
I'm fairly confident that this proof is correct. What I don't understand is why the same proof does not apply to proving that a holomorphic function defined on a compact subset of $\mathbb{C}$ is constant, which is not true.
I would point out two reasons for why the proof does not work for compact subsets of $\mathbb{C}$.
1) In general a compact subspace $K \subset \mathbb{C}$ is not connected. Of course this is not the real problem, because there are non-constant functions on connected and compact subspaces, so you can ask the question "why doesn't the proof work for compact and connected subsets of $\mathbb{C}$?"
2) The real problem I think is that for a compact subspace $K \subset \mathbb{C}$, you cannot guarantee that the set of points where the function attains its maximum modulus is open in $K$, think about the identity function restricted to the unit disc, for example. In the case of a Riemann surface, the existence of charts around any point and the usual Maximum Modulus Theorem for holomorphic functions on $\mathbb{C}$ guarantee that this set is open.