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

Property assignment dropped with pure_getters=true #2838

Closed
filipesilva opened this issue Jan 22, 2018 · 3 comments · Fixed by #2839
Closed

Property assignment dropped with pure_getters=true #2838

filipesilva opened this issue Jan 22, 2018 · 3 comments · Fixed by #2839
Labels

Comments

@filipesilva
Copy link

filipesilva commented Jan 22, 2018

Bug report or feature request?
Bug report

ES5 or ES6+ input?
ES5

Uglify version (uglifyjs -V)
[email protected]

JavaScript input

// test.js
var MatFab = /*@__PURE__*/ (function () {
  function MatFab(button, anchor) {
    (button || anchor).color = 'accent';
  }
  return MatFab;
}());
var button = {};
MatFab(button);
console.log(button);

The uglifyjs CLI command executed or minify() options used.

uglifyjs -c toplevel,pure_getters=true -b -- test.js

JavaScript output or error produced.

var button = {};

(function() {
    return function(button, anchor) {};
})()(button), console.log(button);

Other information

The (button || anchor).color = 'accent'; statement is dropped when the pure_getters compress is used.

Disabling pure_getters or changing the statement to button.color = 'accent'; will cause it to not be dropped anymore.

I think this is a bug because button.color = 'accent'; and (button || anchor).color = 'accent'; should not have different results. I agree it's a side effect though.

Related to angular/devkit#388

@kzc
Copy link
Contributor

kzc commented Jan 22, 2018

It appears to be a regression from [email protected]. The commit that introduced the issue is 0b0eac1

@alexlamsl
Copy link
Collaborator

Thanks to @filipesilva for the detailed report, and @kzc for the bisection - got the cause and fix down much quicker 👍

PR coming up.

@filipesilva
Copy link
Author

@alexlamsl awesome, thank you so much!

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

Successfully merging a pull request may close this issue.

3 participants