Summary: pure function too pure
pure int fun(int d, int divisor)
if (d < 0)
d -= divisor - 1;
return d / divisor;
This doesn't compile because d is assumed to be constant. It doesn't have to
because it's a private copy of the function. Beware when fixing this - any
indirectly-referenced data is not part of function's private state.