Thanks for your bug report. I was able to reproduce this issue. It is due to how $onpoly() uses windows regions to determine if polygons are overlapped. A zero area polygon results in an empty combined region which means it cannot be detected using this method. I would need to extend $onpoly() to perform the the end point tests you mentioned specifically to detect this case. This should be in the next beta.