From f7c6f60a47a71a2e2bb63828a6b71369e0d4a19b Mon Sep 17 00:00:00 2001 From: kzc Date: Wed, 6 Sep 2017 13:16:21 -0400 Subject: [PATCH] add more known globals to `unsafe` option --- lib/compress.js | 2 +- test/compress/dead-code.js | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/compress.js b/lib/compress.js index 7c60b763..45cc79e5 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -693,7 +693,7 @@ merge(Compressor.prototype, { return node instanceof AST_SymbolRef && node.definition().undeclared; } - var global_names = makePredicate("Array Boolean console Date Error Function Math Number RegExp Object String"); + var global_names = makePredicate("Array Boolean console Date Error EvalError Function JSON Math Number parseInt RangeError ReferenceError RegExp Object String SyntaxError TypeError URIError"); AST_SymbolRef.DEFMETHOD("is_declared", function(compressor) { return !this.definition().undeclared || compressor.option("unsafe") && global_names(this.name); diff --git a/test/compress/dead-code.js b/test/compress/dead-code.js index bee7994e..6ae368fa 100644 --- a/test/compress/dead-code.js +++ b/test/compress/dead-code.js @@ -243,12 +243,20 @@ issue_2233_1: { console.log; Date; Error.name; + EvalError; Function.length; + JSON; Math.random; Number.isNaN; + parseInt; RegExp; Object.defineProperty; String.fromCharCode; + RangeError; + ReferenceError; + SyntaxError; + TypeError; + URIError; } expect: {} expect_stdout: true