It's not difficult to find a function $f\colon \mathbb R \to \mathbb R$ such that its restriction to any (not trivial) interval is surjective. Does anyone know whether such a function is necessarily not (Lebesgue) measurable? I'm pretty sure this is the case, but I cannot prove it.

Here is an example of such an $f$. Let $\sim$ be the equivalence relation defined by $x \sim y$ if and only if $x-y \in \mathbb Q$, with $x$ and $y$ in $\mathbb R$. Let $C$ be $\mathbb R/\sim$ (here we need the axiom of choice), and denote with $\pi$ the projection. Since $\mathbb Q$ is countable, $C$ must have the cardinality of the continuum. Let $\varphi \colon C \to \mathbb R$ a bijection. Then $f:=\varphi \circ \pi$ has the required property.