I've been trying to find the error in this approach to calculate the work of a uniform gravitational field on an object falling to the ground in the $-y$ direction. $$\begin{align} W &= \int_{i}^{f} \vec{F} \cdot \mathrm{d}\vec{s} \\ &= -mg \int_{i}^{f} \hat{y} \cdot \mathrm{d}\vec{s} \end{align}$$ Because object is moving down, $\mathrm{d}\vec{s} = -\mathrm{d}\vec{y}$ $$\begin{align} &= -mg \int_{i}^{f} \hat{y} \cdot -\mathrm{d}\vec{y} \\ &= mg \int_{i}^{f} \hat{y} \cdot \mathrm{d}\vec{y} \end{align}$$ Because $ \hat{y}$ is parallel to $\mathrm{d}\vec{y}$, then the vector dot product is $\mathrm{d}y$ $$\begin{align} &= mg \int_{i}^{f} \mathrm{d}y \\ &= mg (h_f -h_i) \end{align}$$ which is less than zero when $h_f < h_i$, and thus obviously wrong. Yet a simplistic approach has $W = FD$, with the two vectors parallel, and it is clear that the work is really positive.
Can someone point out which axiom of math or physics my math conflicts with? My instinct is that once the scalar $\mathrm{d}y$ is obtained, the integral "transforms" to a new coordinate system where the motion is understood to be in the positive direction, rather than the negative as the integral is set up.
Is this a common mistake? Is the lesson that when performing a dot product within an integral, the sign of the integral has to checked analytically? Or is there a simpler axiom I'm missing? I could easily envision myself, if I was writing code, to try to follow the algebra without thinking too analytically, and thus getting a wrong answer. I've studied undergrad linear algebra, vector calculus, and intermediate mechanics, but I don't recall ever seeing this issue arise.