Suppose that $f:{\bf C}\mapsto {\bf C}$ is a $C^\infty$ function such that $f(z)\in\overline{{\bf Q}(z)}$ for all $z\in {\bf C}$, ie $f(z)$ is algebraic over the field ${\bf Q}(z)$ generated by $z$ over ${\bf Q}$, for all $z\in{\bf C}$.

Is it true that $f(z)\in\bar{\bf Q}[z]$, in other words, that $f(z)$ is a polynomial function in $z$, with coefficients in $\bar{\bf Q}$ ?

One of my colleagues sketched an argument showing that this is true, which uses Baire's category theorem. I would like to know if anybody knows a reference for this result in the mathematical literature (or possibly a counterexample - I haven't checked his argument in detail) .

This question is related to the question Maps preserving algebraic numbers but the properties requested from $f$ are stronger here.