inference: fix too conservative effects for recursive cycles
The :terminates effect bit must be conservatively tainted unless recursion cycle has been fully resolved. As for other effects, there's no need to taint them at this moment because they will be tainted as we try to resolve the cycle.
- fixes #52938
- xref #51092
Added a TODO comment, and I'm planning to merge this soon.
How did you end up addressing the correctness problem Keno noted in his review?
I plan to address that in the future. Practically I don't think any issues will arise with this commit as it is.
This PR breaks one of the test cases in #49119, but that case might not be very important in reality. That is because if function f calls Core.Compiler.return_type(g, ...), it is likely to actually call g, so if there is a cycle between f and g, :terminates will eventually be tainted anyway.
This PR fixes many other broken test cases and actually solves issues in the GPUCompiler stack, so I want to move forward with it once CI succeeds.