Skip to content

Property assignment dropped with pure_getters=true #2838

Closed

Description

@filipesilva

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

Activity

  1. kzc commented on Jan 22, 2018

    @kzc
    Contributor

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

  2. alexlamsl commented on Jan 22, 2018

    @alexlamsl
    Collaborator

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

    PR coming up.

  3. added a commit that references this issue on Jan 22, 2018
    c293fcf
  4. added a commit that references this issue on Jan 22, 2018
    ec42025
  5. filipesilva commented on Jan 23, 2018

    @filipesilva
    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions