Closed ghost closed 9 years ago
I haven't really touched the TCO code so I can't immediately tell why this is occurring but I know Fay is limited in when it can detect tail calls. That the if
alternative works gives me hope that it's solvable at least, preferably in the optimizer instead of changing the implementation of when
but either solution is fine.
I don't expect to be able to tackle this myself anytime soon so if you are willing to look into this I'd very much appreciate it!
I don't believe this is resolvable via tail call elimination since when
is declared as Bool -> Fay a -> Fay ()
making it equivalent to if t < 500 then loop >> return () else return ()
in this case.
Is updating when
to Bool -> Fay () -> Fay ()
matching base
an option? I presume it was declared the way it is to avoid the need for explicit void
in some cases?
Sorry for the late reply.
Good catch! I think this is simply a mistake, I don't want fay-base to differ from base unless necessary.
This was fixed by #428
The following code works (except that the first putStrLns are swallowed). However when I comment the "if" line and uncomment the "when" line I get a "too much recursion"-error and the program halts prematurely.