Uglifyjs: Assignment in return statement is dropped by compressor.

Created on 26 Dec 2017  路  1Comment  路  Source: mishoo/UglifyJS

Bug report or feature request?

Bug report.

ES5 or ES6+ input?

ES5.

Uglify version (uglifyjs -V)

uglify-js 3.3.2

JavaScript input

function newObject() {
  var object;
  return object = {
    method: function() {
      return object;
    }
  };
}

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

uglifyjs -c < index.js

JavaScript output or error produced.

function newObject(){var object;return{method:function(){return object}}}

As shown the generated compressed code is missing the assignment to object in the return statement, and thus object is always undefined and the code is broken.

bug

Most helpful comment

@mbostock thanks for the detailed report - investigating.

>All comments

@mbostock thanks for the detailed report - investigating.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lhtdesignde picture lhtdesignde  路  3Comments

buu700 picture buu700  路  5Comments

chrismanley picture chrismanley  路  5Comments

JoeUX picture JoeUX  路  3Comments

alexlamsl picture alexlamsl  路  4Comments