From: Alex Lam S.L Date: Sun, 18 Feb 2018 13:51:27 +0000 (+0800) Subject: fix crash in `may_throw()` (#2932) X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=4b5993ff15bc99bcb897611974529cbc92543211;p=UglifyJS.git fix crash in `may_throw()` (#2932) fixes #2931 --- diff --git a/lib/compress.js b/lib/compress.js index 2cc8282a..f3770cce 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -2864,7 +2864,7 @@ merge(Compressor.prototype, { return this.value.may_throw(compressor); }); def(AST_Return, function(compressor){ - return this.value.may_throw(compressor); + return this.value && this.value.may_throw(compressor); }); def(AST_Sequence, function(compressor){ return any(this.expressions, compressor); diff --git a/test/compress/collapse_vars.js b/test/compress/collapse_vars.js index d0a5df85..688f54c4 100644 --- a/test/compress/collapse_vars.js +++ b/test/compress/collapse_vars.js @@ -4642,3 +4642,26 @@ issue_805: { } } } + +issue_2931: { + options = { + collapse_vars: true, + unused: true, + } + input: { + console.log(function() { + var a = function() { + return; + }(); + return a; + }()); + } + expect: { + console.log(function() { + return function() { + return; + }(); + }()); + } + expect_stdout: "undefined" +}