Perhaps it's because they implemented the "Sunrise equation" naively, which becomes indeterminate for high latitudes when the Sun is close to the maximum? https://en.wikipedia.org/wiki/Sunrise_equation cos(\Omega) = - tan(\phi) x tan(\delta) Where \Omega = hour angle (sunrise, sunset offset from noon), \phi = latitude, \delta = sun declination. Clearly if the right hand side gets big enough (>1), this doesn't work.
Angles are always such a pain. In my experience it's worth applying trigonometric identities and working in terms of unit vectors, sines, and cosines instead of using angles directly. In this case angles seem unavoidable, though: acos(tan(x)*tan(y)) doesn't simplify to anything useful.