Skip to content
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

heisenbug #4097

Closed
kzc opened this issue May 26, 2021 · 4 comments · Fixed by #4111
Closed

heisenbug #4097

kzc opened this issue May 26, 2021 · 4 comments · Fixed by #4111

Comments

@kzc
Copy link
Contributor

kzc commented May 26, 2021

  • Rollup Version: rollup v2.50.0
  • Operating System (or Browser): n/a
  • Node Version (if applicable): v16.1.0

Repro

2.50.0 REPL

$ cat heisenbug.js 
function heisenbug() {
    var a;
    function f(b) {
        if (a) console.log(a === b.c ? "PASS" : "FAIL");
        a = b.c;
    }
    function g() {}
    function h() {
        f({
            c: g
        });
    }
    h();
    h();
}
heisenbug();
heisenbug();

// if following line is commented out then rollup generates an empty chunk
//console.log(123);

Expected Behavior

$ cat heisenbug.js | node
PASS
PASS

Actual Behavior

$ cat heisenbug.js | rollup

- → stdout...

(!) Generated an empty chunk

This example worked in rollup 2.48.0.

@lukastaegert
Copy link
Member

Thanks a lot for spotting this one! This was the result of the new lazy object deoptimization, which did not request new tree-shaking passes when an object was deoptimized. Fixed in #4111.

@kzc
Copy link
Contributor Author

kzc commented May 28, 2021

Glad you found the problem. This bug took quite a while to isolate.

@lukastaegert
Copy link
Member

And I am glad you did. These kind of tests turn out to be useful time and again in the future when the logic is expanded or fundamentally changed.

@kzc
Copy link
Contributor Author

kzc commented May 28, 2021

Most of my recent bug reports were adapted from the uglify-js test suite, by the way. This one was particularly strange though. I initially thought it was a strict/non-strict mode thing.

All the failing non-strict mode tests were ignored as Rollup assumes it is always dealing with ES module inputs. I don't think that's of concern to most users.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants