If y is a function of x, then you also need to apply the chain rule to get:
Normally you would only treat y as a constant when doing partial differentiation. And you don't know what is, this is normally what you are trying to express as a function of x and y.
Normally, "y" is used as a variable or function of x. You have been told repeatedly that if y is independent of x, then so is f(y) for any f and so df(y)/dx= 0. If, however, y is itself some function of x, then df(y)/dx= (df/dy)(dy/dx), by the chain rule.