Even I, who haven't looked at asy for very many years, and when I did I was no asy programmer, can see the problem.
I don't want to do homework so not posting the answer but my top tip for discovering the bug is to step through your code on paper...
Just updating now...
Eta:
No wait - that's an older version. I can say it seems to be 1.43 that has the issue - not noticed it before.