Pauan/rollup-plugin-purs

"Maximum call stack size exceeded" in remove-iife

FrigoEU opened this issue · 0 comments

Hey,

I'm getting a stack overflow in remove-iife. I have a minimal testcase that can reproduce the endless loop that causes the "Maximum call stack size exceeded" error to get thrown.

var x = {a: 7};
(function(x){x + 5;})(x.a);

What seems to be happening is that the inlineVisitor is inlining x.a into x, then visits the MemberExpression x.a, inlines x.a into x again, etc etc.

I'm having a hard time wrapping my head around inlineVisitor (and babel.js bindings in general), but I'm pretty sure the problem pops up when an argument of the function you're processing (in our case x) is called the same as a part of the expression you're inlining into the body of the function (in our case x.a). I think whatever you're inlining into the function should not be visited by the inlineVisitor ever, but I'm not 100% sure.