Amazingly... an internal compiler crash. Unrolling the code like this was the only way I found to make it to compile.
On getting x,y,ix,iy out of the #if, you're right, but I'm not sure how to change it now in GitHub. Should I remove this pull request and open a new one, or can I modify it? Otherwise, you can also do the change yourself, it'll be ok.