In our case, we are calculating not a partial derivative of but the ordinary derivative of with respect to . To answer your question, we don't have to replace and with expressions for if we regard them as functions of , as long as we remember that

is a function of one variable, .