Keep master in sync with harmony
authorAnthony Van de Gejuchte <anthonyvdgent@gmail.com>
Mon, 20 Jun 2016 12:18:47 +0000 (14:18 +0200)
committerRichard van Velzen <rvanvelzen1@gmail.com>
Mon, 20 Jun 2016 16:42:17 +0000 (18:42 +0200)
 * Do not mangle when no mangle is required
 * Improve use_asm reset while printing code

lib/output.js
test/mocha/directives.js

index 10465e2..5db1356 100644 (file)
@@ -404,7 +404,7 @@ function OutputStream(options) {
 
     AST_Node.DEFMETHOD("print", function(stream, force_parens){
         var self = this, generator = self._codegen, prev_use_asm = use_asm;
-        if (self instanceof AST_Directive && self.value == "use asm") {
+        if (self instanceof AST_Directive && self.value == "use asm" && stream.parent() instanceof AST_Scope) {
             use_asm = true;
         }
         function doit() {
@@ -419,7 +419,7 @@ function OutputStream(options) {
             doit();
         }
         stream.pop_node();
-        if (self instanceof AST_Lambda) {
+        if (self instanceof AST_Scope) {
             use_asm = prev_use_asm;
         }
     });
@@ -1221,7 +1221,7 @@ function OutputStream(options) {
         output.print_string(self.getValue(), self.quote, in_directive);
     });
     DEFPRINT(AST_Number, function(self, output){
-        if (use_asm && self.start.raw != null) {
+        if (use_asm && self.start && self.start.raw != null) {
             output.print(self.start.raw);
         } else {
             output.print(make_num(self.getValue()));
index 45f454b..8259475 100644 (file)
@@ -224,7 +224,7 @@ describe("Directives", function() {
 
         for (var i = 0; i < tests.length; i++) {
             assert.strictEqual(
-                uglify.minify(tests[i][0], {fromString: true, quote_style: 3, compress: false}).code,
+                uglify.minify(tests[i][0], {fromString: true, quote_style: 3, compress: false, mangle: false}).code,
                 tests[i][1],
                 tests[i][0]
             );