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

Regression: 3.1.10 fails to uglify code that 3.1.9 could #2497

Closed
watanas opened this issue Nov 20, 2017 · 1 comment · Fixed by #2502
Closed

Regression: 3.1.10 fails to uglify code that 3.1.9 could #2497

watanas opened this issue Nov 20, 2017 · 1 comment · Fixed by #2502
Labels

Comments

@watanas
Copy link

watanas commented Nov 20, 2017

Minimal code sample:

function sample() {
  if (true) {
    for (var i = 0; i < 1; ++i) {
      for (var k = 0; k < 1; ++k) {
        var value = 1;
        var x = value;
        value = x ? x + 1 : 0;
      }
    }
  } else {
    for (var i = 0; i < 1; ++i) {
      for (var k = 0; k < 1; ++k) {
        var value = 1;
      }
    }
  }
}
stevens-imac:wgs.js watanas$ ./node_modules/.bin/uglifyjs --version
uglify-js 3.1.10
stevens-imac:wgs.js watanas$ ./node_modules/.bin/uglifyjs --compress -- dist/sample.js
ERROR: candidate.value.definition is not a function
    at collapse (eval at <anonymous> (/Users/watanas/dev/DMG-Dreamcatcher/dreamcatcher/firefly.js/wgs.js/node_modules/uglify-js/tools/node.js:21:1), <anonymous>:6079:61)
    at tighten_body (eval at <anonymous> (/Users/watanas/dev/DMG-Dreamcatcher/dreamcatcher/firefly.js/wgs.js/node_modules/uglify-js/tools/node.js:21:1), <anonymous>:5916:17)
    at eval (eval at <anonymous> (/Users/watanas/dev/DMG-Dreamcatcher/dreamcatcher/firefly.js/wgs.js/node_modules/uglify-js/tools/node.js:21:1), <anonymous>:7439:9)
    at AST_Node.eval [as optimize] (eval at <anonymous> (/Users/watanas/dev/DMG-Dreamcatcher/dreamcatcher/firefly.js/wgs.js/node_modules/uglify-js/tools/node.js:21:1), <anonymous>:5320:23)
    at Object.before (eval at <anonymous> (/Users/watanas/dev/DMG-Dreamcatcher/dreamcatcher/firefly.js/wgs.js/node_modules/uglify-js/tools/node.js:21:1), <anonymous>:5303:24)
    at AST_Node.eval [as transform] (eval at <anonymous> (/Users/watanas/dev/DMG-Dreamcatcher/dreamcatcher/firefly.js/wgs.js/node_modules/uglify-js/tools/node.js:21:1), <anonymous>:2955:35)
    at eval (eval at <anonymous> (/Users/watanas/dev/DMG-Dreamcatcher/dreamcatcher/firefly.js/wgs.js/node_modules/uglify-js/tools/node.js:21:1), <anonymous>:3002:31)
    at Object.before (eval at <anonymous> (/Users/watanas/dev/DMG-Dreamcatcher/dreamcatcher/firefly.js/wgs.js/node_modules/uglify-js/tools/node.js:21:1), <anonymous>:5298:9)
    at AST_Node.eval [as transform] (eval at <anonymous> (/Users/watanas/dev/DMG-Dreamcatcher/dreamcatcher/firefly.js/wgs.js/node_modules/uglify-js/tools/node.js:21:1), <anonymous>:2955:35)
    at eval (eval at <anonymous> (/Users/watanas/dev/DMG-Dreamcatcher/dreamcatcher/firefly.js/wgs.js/node_modules/uglify-js/tools/node.js:21:1), <anonymous>:2974:25)
stevens-imac:wgs.js watanas$ npm install uglify-js@3.1.9
+ uglify-js@3.1.9
updated 1 package in 8.493s
stevens-imac:wgs.js watanas$ ./node_modules/.bin/uglifyjs --version
uglify-js 3.1.9
stevens-imac:wgs.js watanas$ ./node_modules/.bin/uglifyjs --compress -- dist/sample.js
function sample(){for(var i=0;i<1;++i)for(var k=0;k<1;++k){var value,x=value=1;value=x?x+1:0}}
stevens-imac:wgs.js watanas$ 
@kzc
Copy link
Contributor

kzc commented Nov 20, 2017

Confirmed bug. Thanks for the report.

Temporary bug workaround: uglifyjs -c collapse_vars=false

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