If you say "this function f operates on the integers", you can't turn around and then go "ooh but it has solutions in the rationals!" No it doesn't, it doesn't exist in that space.

You can't do this for general functions, but it's fine to do in cases where the definition of f naturally embeds into the rationals. For example, a polynomial over Z is also a polynomial over Q or C.