-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix infinite recursion in function inlining #2445
Conversation
@alexlamsl Something is odd here. The tests Feel free to either take over this PR, or close and replace it with a fix of your own. In either case, the new tests can be used. |
@kzc thanks for taking a stab at this. If I understand the issue correctly, before #2427, function inlining only works within the same scope, thus avoiding this infinite recursion problem beautifully. Let's see if I can fix that root cause, but in any case I truly appreciate all the test cases here and shall be |
The more I think about it, the AST must be damaged or cross linked in some way from function inlining, as ASTs are finite and infinite recursion should not be an issue in |
In the meantime I think it'd be a good idea to |
Fair point - let me dig up the docs and do that before resume work on the new PR. Edit: done. |
You need to have a reference cycle of |
Ah - of course! That riddle is solved. Can single-use function cycles exist in non-dead code? I suspect not.
Indeed - I was impressed by how the generated code changed in the tests when calling 1, 2 and 3 of the recursive functions from main. |
I don't think so either - see #2446 (comment) |
It makes you wonder what the code in the wild triggering this issue actually did or how it was bundled in the first place. |
It could be something like: function factorial(n) {
return n < 1 ? 1 : factorial(n - 1);
}
if (DEBUG) console.log(factorial(10)); and then compress with |
Yeah, unlikely, but I guess. It's a real head-scratcher. |
You've saved my hair - please don't make me feel bad by losing any of yours 😅 |
fixes #2442