It could matter, and you should tell the doctor. As one example, if you are having a blood test, they might look at sugar content or similar measurements which are affected by recent consumption of food, so the odds become high that you will have an anomalously high value (and they could worry that you are diabetic, perhaps, or something else).
They tell you not to eat so you have background level concentrations in the blood or perhaps urine or whatever (to avoid the effects of eating, which will vary according to what and how much you eat and make interpretation of results way harder). I did the same thing recently (ate something out of habit in the morning), still did the tests but then the doctor had to take that into account when looking at the results, making the interpretation less reliable.
Obviously, if you just purged your system for some internal visual exam like a colonoscopy, or whatever, having food (even colored liquid) in there could be a problem as well.