If i remember correctly, I remember something in one of the newer releases saying something about how it can push players or something, if I am remembering correctly, it could just be that you are un-pushable or something. not too sure tho.
really you should do something like this
if turtle.forward() then -- the turtle can move
dig()
dist = dist + 1
elseif turtle.detect() then -- there is a block in the way
-- handle that
elseif turtle.getFuelLevel() == 0 then -- the turtle is out of fuel
-- handle that
elseif turtle.attack() then
while turtle.attack() do end -- there is no need for a call to sleep here, turtle.attack yields so you wont get any errors...
else
error("The turtle cannot move for an unknown reason", 0)
end
also in your dig have the sleep value (for the gravel/sand) as 0.8 as this is the time it takes for a block to fall. no point checking any quicker than that...