Let $f: A \subseteq \mathbb R \to \mathbb R$ be continuous on $A$. Let $g(a) = \lim_{x \to a}f(x)$ be defined on all $A$. Is $g$ necessarily continuous?
I am confused about the answer, since I have what seem to be valid arguments in both ways:
A limit can have discontinuities. Every derivative is a limit of a continuous function, yet derivatives can have discontinuities, the classic example being the derivative of $0 \mapsto 0, x \mapsto x^2 \sin 1/x$.
A limit must be continuous. Since $f$ is continuous on $A$, $f$ is equal to its limit on $A$. Thus, $g$, which is the limit of $f$, equals $f$, and since $f$ is continuous, $g$ is continuous as well.
This argument seems to be valid provided that $a \in A$. However, for $a \notin A$, this argument is not applicable. This would suggest: $g$ may have points of discontinuity, but they must be on the boundary of $A$, because they are limit points of $A$ but not elements of $A$. But the example above has discontinuities in the middle of its domain.
Where is my mistake?