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

treeshake bug: __proto__ side effects in object literals ignored #4094

Closed
kzc opened this issue May 25, 2021 · 1 comment · Fixed by #4112
Closed

treeshake bug: __proto__ side effects in object literals ignored #4094

kzc opened this issue May 25, 2021 · 1 comment · Fixed by #4112

Comments

@kzc
Copy link
Contributor

kzc commented May 25, 2021

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

Repro

$ cat proto.js 
let getter_effect = "FAIL";
let setter_effect = "FAIL";
let proto = {
    get foo() {
        getter_effect = "PASS";
    },
    set bar(value) {
        setter_effect = "PASS";
    }
};
let obj1 = {
    __proto__: proto
};
let obj2 = {
    __proto__: proto
};
let unused = obj1.foo;
obj2.bar = 0;
console.log(getter_effect, setter_effect);

Expected Behavior

$ cat proto.js | node
PASS PASS

Actual Behavior

$ cat proto.js | rollup --silent | node
FAIL FAIL
$ cat proto.js | rollup --silent
let getter_effect = "FAIL";
let setter_effect = "FAIL";
console.log(getter_effect, setter_effect);
@lukastaegert
Copy link
Member

Thanks for spotting, turns out there was quite some potential improvement left. Fix at #4112.

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