Let $G$ be a region in the complex plane and $S$ a closed subset of $G$. Assume that a function $f:G\to \mathbb{C}$ is continuous and that it's analytic on $G\setminus S$. Under certain assumptions about $S$ it can be deduced that $f$ is analytic on whole $G$.
When $S$ is a point, this is the case of removable singularity.
When $S$ is a line segment: I used Morera's theorem ("integral over every closed triangle contained in $G$ is zero" implies analyticity) to show this case. When the triangle intersects the line segment $S$, I "make it go around" the line segment (picture below). We can do this, since $G$ is open, there must be a positive distance from the line segment $S$ to the boundary of $G$, so for a small enough perturbation the path stays in $G$.
(NOTE: If only one side of the triangle intersects $S$, only that side needs to be made go around and if the triangle doesn't intersect $S$, then we are done, since $f$ is analytic on $G\setminus S$, the integral is already zero (because this characterizes analytic functions).)
Now, the integral over this path goig around is zero. Then pass to a limit and since $f$ is continuous, I see that the integrals "along the line segment" cancel and that the integral tends to the integral over the original path (the triangle itself). Is there an easier way to do this?
Is there also some sort of more general theorem about what $S$ can be? My deduction isn't completely rigorous, but I think we can "go around" many types of sets $S$.
