From: Mihai Bazon Date: Wed, 20 Nov 2013 19:13:16 +0000 (+0200) Subject: Fix faulty compression X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=50b8d7272c3b0c7a222e5d6e433c9736f920434c;p=UglifyJS.git Fix faulty compression `String(x + 5)` is not always the same as `x + "5"`. Overlooked that. :-( Close #350 --- diff --git a/lib/compress.js b/lib/compress.js index c60ee19e..3cc59e2c 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -2031,16 +2031,6 @@ merge(Compressor.prototype, { && self.right.getValue() === "" && self.left instanceof AST_Binary && self.left.operator == "+" && self.left.is_string(compressor)) { return self.left; - } else if (self.operator == "+" && self.right instanceof AST_String - && self.right.getValue() === "" && self.left instanceof AST_Binary - && self.left.operator == "+" && self.left.right instanceof AST_Number) { - return make_node(AST_Binary, self, { - left: self.left.left, - operator: "+", - right: make_node(AST_String, self.right, { - value: String(self.left.right.value) - }) - }); } if (compressor.option("evaluate")) { if (self.operator == "+") { diff --git a/test/compress/issue-269.js b/test/compress/issue-269.js index 70e82d08..1d41dea6 100644 --- a/test/compress/issue-269.js +++ b/test/compress/issue-269.js @@ -54,15 +54,13 @@ strings_concat: { input: { f( String(x + 'str'), - String('str' + x), - String(x + 5) + String('str' + x) ); } expect: { f( x + 'str', - 'str' + x, - x + '5' + 'str' + x ); } -} \ No newline at end of file +}