You will need an invokelatest
in there. Functions run in a fixed world-age, and eval
will not respect that. This is (part of) why people tell you not to write code this way.
A ‘working’ version of your function would be
f(s) = invokelatest(hasmethod, eval(Meta.parse(s)), (Real,))