p42ai / js-assistant

120+ refactorings and code-assists for Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=p42ai.refactor
MIT License
119 stars 7 forks source link

`You can remove the IIFE` is unsafe #52

Closed AlexXanderGrib closed 1 year ago

AlexXanderGrib commented 1 year ago

Code:

function tick() { /* works with canvas */ }

(function loop() {
  tick();
  requestAnimationFrame(loop);
})();

p42 suggests to remove IIFE and deems it safe. Result:

{
  tick();
  requestAnimationFrame(loop); // So loop is undefined
}
lgrammel commented 1 year ago

Thanks for the bug report!

Starting in v1.147.2, remove IIFE is not available any more when there are self-references to the function. Please re-open if the bug still occurs.