diff --git a/lib/output.js b/lib/output.js index 9198719d..8919a392 100644 --- a/lib/output.js +++ b/lib/output.js @@ -157,7 +157,7 @@ function OutputStream(options) { case "\u2029": return "\\u2029"; case "\ufeff": return "\\ufeff"; case "\0": - return /[0-7]/.test(get_full_char(str, i+1)) ? "\\x00" : "\\0"; + return /[0-9]/.test(get_full_char(str, i+1)) ? "\\x00" : "\\0"; } return s; }); diff --git a/lib/scope.js b/lib/scope.js index 47ea7122..0c861a7d 100644 --- a/lib/scope.js +++ b/lib/scope.js @@ -315,6 +315,7 @@ AST_Toplevel.DEFMETHOD("figure_out_scope", function(options){ ref.reference(options); }); node.thedef = def; + node.reference(options); return true; } })); diff --git a/package.json b/package.json index 2e35d753..8f14aa2e 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "homepage": "https://github.com/mishoo/UglifyJS2/tree/harmony", "author": "Mihai Bazon (http://lisperator.net/)", "license": "BSD-2-Clause", - "version": "3.0.27", + "version": "3.0.28", "engines": { "node": ">=0.8.0" }, diff --git a/test/compress/ascii.js b/test/compress/ascii.js index 9662d413..3c7cc5cf 100644 --- a/test/compress/ascii.js +++ b/test/compress/ascii.js @@ -13,7 +13,7 @@ ascii_only_true: { "\x20\x21\x22\x23 ... \x7d\x7e\x7f\x80\x81 ... \xfe\xff\u0fff\uffff"; } } - expect_exact: 'function f(){return"\\x000\\x001\\x007\\08\\0"+"\\0\\x01\\x02\\x03\\x04\\x05\\x06\\x07\\b\\t\\n\\v\\f\\r\\x0e\\x0f"+"\\x10\\x11\\x12\\x13\\x14\\x15\\x16\\x17\\x18\\x19\\x1a\\x1b\\x1c\\x1d\\x1e\\x1f"+\' !"# ... }~\\x7f\\x80\\x81 ... \\xfe\\xff\\u0fff\\uffff\'}' + expect_exact: 'function f(){return"\\x000\\x001\\x007\\x008\\0"+"\\0\\x01\\x02\\x03\\x04\\x05\\x06\\x07\\b\\t\\n\\v\\f\\r\\x0e\\x0f"+"\\x10\\x11\\x12\\x13\\x14\\x15\\x16\\x17\\x18\\x19\\x1a\\x1b\\x1c\\x1d\\x1e\\x1f"+\' !"# ... }~\\x7f\\x80\\x81 ... \\xfe\\xff\\u0fff\\uffff\'}' } ascii_only_false: { @@ -31,5 +31,5 @@ ascii_only_false: { "\x20\x21\x22\x23 ... \x7d\x7e\x7f\x80\x81 ... \xfe\xff\u0fff\uffff"; } } - expect_exact: 'function f(){return"\\x000\\x001\\x007\\08\\0"+"\\0\x01\x02\x03\x04\x05\x06\x07\\b\\t\\n\\v\\f\\r\x0e\x0f"+"\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f"+\' !"# ... }~\x7f\x80\x81 ... \xfe\xff\u0fff\uffff\'}' + expect_exact: 'function f(){return"\\x000\\x001\\x007\\x008\\0"+"\\0\x01\x02\x03\x04\x05\x06\x07\\b\\t\\n\\v\\f\\r\x0e\x0f"+"\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f"+\' !"# ... }~\x7f\x80\x81 ... \xfe\xff\u0fff\uffff\'}' } diff --git a/test/compress/concat-strings.js b/test/compress/concat-strings.js index 867951ff..c7c07ca2 100644 --- a/test/compress/concat-strings.js +++ b/test/compress/concat-strings.js @@ -21,7 +21,7 @@ concat_1: { var c = 1 + x() + 2 + "boo"; var d = 1 + x() + 2 + 3 + "boo"; var e = 1 + x() + 2 + "X3boo"; - var f = "\x00360\08\0"; + var f = "\x00360\x008\0"; } } diff --git a/test/compress/screw-ie8.js b/test/compress/screw-ie8.js index 5d6f1e2c..66559b0b 100644 --- a/test/compress/screw-ie8.js +++ b/test/compress/screw-ie8.js @@ -325,3 +325,69 @@ issue_2120_2: { } expect_stdout: "PASS" } + +issue_2254_1: { + mangle = { + ie8: false, + } + input: { + "eeeeee"; + try { + console.log(f("PASS")); + } catch (e) {} + function f(s) { + try { + throw "FAIL"; + } catch (e) { + return s; + } + } + } + expect: { + "eeeeee"; + try { + console.log(f("PASS")); + } catch (e) {} + function f(e) { + try { + throw "FAIL"; + } catch (t) { + return e; + } + } + } + expect_stdout: "PASS" +} + +issue_2254_2: { + mangle = { + ie8: true, + } + input: { + "eeeeee"; + try { + console.log(f("PASS")); + } catch (e) {} + function f(s) { + try { + throw "FAIL"; + } catch (e) { + return s; + } + } + } + expect: { + "eeeeee"; + try { + console.log(f("PASS")); + } catch (e) {} + function f(t) { + try { + throw "FAIL"; + } catch (e) { + return t; + } + } + } + expect_stdout: "PASS" +} diff --git a/test/mocha/string-literal.js b/test/mocha/string-literal.js index d2eb6a80..f595f29a 100644 --- a/test/mocha/string-literal.js +++ b/test/mocha/string-literal.js @@ -61,9 +61,9 @@ describe("String literals", function() { var tests = [ ['"\\76";', ';">";'], ['"\\0"', '"\\0";'], - ['"\\08"', '"\\08";'], - ['"\\008"', '"\\08";'], - ['"\\0008"', '"\\08";'], + ['"\\08"', '"\\x008";'], + ['"\\008"', '"\\x008";'], + ['"\\0008"', '"\\x008";'], ['"use strict" === "use strict";\n"\\76";', '"use strict"==="use strict";">";'], ['"use\\\n strict";\n"\\07";', ';"use strict";"\07";'] ]; @@ -75,8 +75,8 @@ describe("String literals", function() { }); it("Should not throw error when digit is 8 or 9", function() { - assert.equal(UglifyJS.parse('"use strict";"\\08"').print_to_string(), '"use strict";"\\08";'); - assert.equal(UglifyJS.parse('"use strict";"\\09"').print_to_string(), '"use strict";"\\09";'); + assert.equal(UglifyJS.parse('"use strict";"\\08"').print_to_string(), '"use strict";"\\x008";'); + assert.equal(UglifyJS.parse('"use strict";"\\09"').print_to_string(), '"use strict";"\\x009";'); }); it("Should not unescape unpaired surrogates", function() {