Restricted Cauchy equation on a non-dense domain It is really well known that if $f: \mathbf{R}\to \mathbf{R}$ is continuous and
$$
\forall x,y \in \mathbf{R},\,\,\,\,f(x+y)=f(x)+f(y)
$$
then $f$ is linear, i.e., there exists $a \in \mathbf{R}$ such that $f(x)=ax$ for all $x \in \mathbf{R}$.
More generally, it is known that if  $f: K \to \mathbf{R}$  is continuous, where $K\subseteq \mathbf{R}$ is a non-empty open connected set with $K+K\subseteq K$, then the functional equation
$$
\forall (x,y) \in K^2,\,\,\,\,f(x+y)=f(x)+f(y)\,\,\,\,\,\,\,\,\,\,\,(\star)
$$
implies that $f$ is linear.
Here a related question:

Question. Does there exist a set $S\subseteq \mathbf{R}^2$ which is not dense in $\mathbf{R}^2$, not containing an open connected set, and such that if  $f: \mathbf{R}\to \mathbf{R}$ is continuous function satisfying ($\star$) for all $(x,y) \in S$ then $f$ is linear?

Easy observation: $S$ cannot be bounded (see also the comment of TheoBandit below). Indeed, in the opposite, we could set $f(x)=0$ for all $x$ in a ball with sufficiently large radius; then, any continuous extension will work.
 A: Yes, there is such a domain. Consider,
$$S = \bigcup_{n \in \Bbb{Z}} \{(x, nx) : x \in \Bbb{R}\}.$$
Note that $S$ is not dense and has empty interior. I claim that, if $f : \Bbb{R} \to \Bbb{R}$ is continuous and satisfies
$$f(x + y) = f(x) + f(y)$$
for all $(x, y) \in S$, then $f$ is scalar homogeneous. First, note that $(0, 0) \in S$, hence
$$f(0 + 0) = f(0) + f(0) \implies f(0) = 0.$$
Next, suppose $n \ge 1$ is an integer. I wish to show that $f(nx) = nf(x)$ for all $x$. We proceed by induction.
The base case is clear. Suppose $f(nx) = nf(x)$ for some $n$. Then, because $(x, nx) \in S$, we have
$$f((n + 1)x) = f(x + nx) = f(x) + f(nx) = f(x) + nf(x) = (n + 1)f(x).$$
The claim holds by induction.
Similarly, this holds for $n < 0$. If we assume $n \le 0$ is such that $f(nx) = nf(x)$, then
$$f(x) + f((n - 1)x) = f(x + (n - 1)x) = f(nx) = nf(x),$$
which implies $f((n - 1)x) = (n - 1)f(x)$ as required. By induction,
$$f(nx) = nf(x) \quad \forall n \in \Bbb{Z}, x \in \Bbb{R}.$$
Next, as you might guess, we establish rational scalar homogeneity. However, this follows directly from the integer scalar homogeneity. We have
$$qf\left(\frac{p}{q}x\right) = f\left(q \frac{p}{q}x\right) = f(px) = pf(x) \implies f\left(\frac{p}{q}x\right) = \frac{p}{q}f(x)$$
where $p, q \in \Bbb{Z}$ and $q \neq 0$.
Since the rationals are dense in $\Bbb{R}$, we must have $f(\lambda x) = \lambda f(x)$ for any real $\lambda$, hence $f$ is linear.
