The following is well-known:
Theorem A: If $E$ is an open, connected subset of $\mathbb{R}^n$, then any function $f\colon E\to\mathbb{R}$ that is differentiable everywhere on $E$ with $f'=0$ must be constant.
However, even if $E$ is not open, one can still define the derivative at any point $x_0\in E$ which is not isolated, namely $f'(x_0)$ is the unique linear map $A\colon\mathbb R^n\to\mathbb R$ such that the error$$\|f(x)-f(x_0)-A(x-x_0)\|=o(\|x-x_0\|),$$provided it exists. (For instance, $E$ could be the Cantor set.)
This question is about whether both openness and connectedness of $E$ are needed in Theorem A.
Clearly connectedness is needed. However, it seems to me that the openness assumption is mostly there as a convenient way to
Ensure that $E$ is path-connected;
Ensure that $E$ is locally convex,
either of which would allow one to reduce the problem further. However, I'm uncertain if connectedness by itself is sufficient. More precisely:
Question: Suppose $E$ is connected with no isolated points. Then without assuming that $E$ is open, does Theorem $A$ still hold? If not, would it suffice to assume that $E$ is path-connected?
Remark: I cannot think of any simple case (e.g. $E$ is a rectangle or a piecewise smooth curve or the topologist's sine curve) where it would be false. But perhaps there are more subtle geometries where a counter-example exists?