[Pkg-javascript-commits] [uglifyjs] 20/190: Fix bad parsing of `new new x()()` constructs

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 fcde6109b0138502a445a7571adc810b5b9e68ee
Author: Richard van Velzen <rvanvelzen at experty.com>
Date:   Thu Aug 6 21:27:46 2015 +0200

    Fix bad parsing of `new new x()()` constructs
    
    Fixes #739
---
 lib/parse.js         |  6 +++---
 test/compress/new.js | 12 ++++++++++++
 2 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/lib/parse.js b/lib/parse.js
index ab72ad2..496a673 100644
--- a/lib/parse.js
+++ b/lib/parse.js
@@ -1114,7 +1114,7 @@ function parse($TEXT, options) {
         });
     };
 
-    var new_ = function() {
+    var new_ = function(allow_calls) {
         var start = S.token;
         expect_token("operator", "new");
         var newexp = expr_atom(false), args;
@@ -1129,7 +1129,7 @@ function parse($TEXT, options) {
             expression : newexp,
             args       : args,
             end        : prev()
-        }), true);
+        }), allow_calls);
     };
 
     function as_atom_node() {
@@ -1173,7 +1173,7 @@ function parse($TEXT, options) {
 
     var expr_atom = function(allow_calls) {
         if (is("operator", "new")) {
-            return new_();
+            return new_(allow_calls);
         }
         var start = S.token;
         if (is("punc")) {
diff --git a/test/compress/new.js b/test/compress/new.js
new file mode 100644
index 0000000..4b2c51c
--- /dev/null
+++ b/test/compress/new.js
@@ -0,0 +1,12 @@
+new_statement: {
+    input: {
+        new x(1);
+        new x(1)(2);
+        new x(1)(2)(3);
+        new new x(1);
+        new new x(1)(2);
+        new (new x(1))(2);
+        (new new x(1))(2);
+    }
+    expect_exact: "new x(1);new x(1)(2);new x(1)(2)(3);new new x(1);new new x(1)(2);new new x(1)(2);(new new x(1))(2);"
+}

-- 
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