[Pkg-javascript-commits] [uglifyjs] 19/190: Don't change sequences that influence lexical binding in calls

Antonio Terceiro terceiro at moszumanska.debian.org
Sun Aug 7 23:17:09 UTC 2016


This is an automated email from the git hooks/post-receive script.

terceiro pushed a commit to annotated tag upstream/2.7.0
in repository uglifyjs.

commit e3bd223dac41ed8fcbbc3a139d78c68bcd50f628
Author: Richard van Velzen <rvanvelzen at experty.com>
Date:   Tue Aug 25 10:53:35 2015 +0200

    Don't change sequences that influence lexical binding in calls
    
    Fixes #782
---
 lib/compress.js            | 14 +++++---------
 test/compress/issue-782.js | 23 +++++++++++++++++++++++
 2 files changed, 28 insertions(+), 9 deletions(-)

diff --git a/lib/compress.js b/lib/compress.js
index ac306fc..51dd66f 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -1910,15 +1910,11 @@ merge(Compressor.prototype, {
         if (!compressor.option("side_effects"))
             return self;
         if (!self.car.has_side_effects(compressor)) {
-            // we shouldn't compress (1,eval)(something) to
-            // eval(something) because that changes the meaning of
-            // eval (becomes lexical instead of global).
-            var p;
-            if (!(self.cdr instanceof AST_SymbolRef
-                  && self.cdr.name == "eval"
-                  && self.cdr.undeclared()
-                  && (p = compressor.parent()) instanceof AST_Call
-                  && p.expression === self)) {
+            // we shouldn't compress (1,func)(something) to
+            // func(something) because that changes the meaning of
+            // the func (becomes lexical instead of global).
+            var p = compressor.parent();
+            if (!(p instanceof AST_Call && p.expression === self)) {
                 return self.cdr;
             }
         }
diff --git a/test/compress/issue-782.js b/test/compress/issue-782.js
new file mode 100644
index 0000000..cce15fd
--- /dev/null
+++ b/test/compress/issue-782.js
@@ -0,0 +1,23 @@
+remove_redundant_sequence_items: {
+    options = { side_effects: true };
+    input: {
+        (0, 1, logThis)();
+        (0, 1, _decorators.logThis)();
+    }
+    expect: {
+        (0, logThis)();
+        (0, _decorators.logThis)();
+    }
+}
+
+dont_remove_lexical_binding_sequence: {
+    options = { side_effects: true };
+    input: {
+        (0, logThis)();
+        (0, _decorators.logThis)();
+    }
+    expect: {
+        (0, logThis)();
+        (0, _decorators.logThis)();
+    }
+}

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/uglifyjs.git



More information about the Pkg-javascript-commits mailing list