[Pkg-javascript-commits] [node-acorn-jsx] 384/484: Revert "Disallow parentheses in lvalue except as in computed keys or default values."

Bastien Roucariès rouca at moszumanska.debian.org
Sat Aug 19 14:21:00 UTC 2017


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

rouca pushed a commit to branch master
in repository node-acorn-jsx.

commit d1f95ece42e0a69aa2c4aaf2360ce3c904e1f696
Author: Ingvar Stepanyan <me at rreverser.com>
Date:   Mon Jan 12 20:31:38 2015 +0200

    Revert "Disallow parentheses in lvalue except as in computed keys or default values."
    
    This reverts commit 85087f2a0951f60ca035ca6d785e4bab6d96d8f7.
    Fixes #193.
---
 acorn.js              |  7 -------
 test/tests-harmony.js | 20 +++++++++-----------
 test/tests.js         |  4 ++--
 3 files changed, 11 insertions(+), 20 deletions(-)

diff --git a/acorn.js b/acorn.js
index 90eee06..3836dc4 100644
--- a/acorn.js
+++ b/acorn.js
@@ -2002,18 +2002,14 @@
 
   function parseMaybeAssign(noIn) {
     var start = storeCurrentPos();
-    var oldParenL = metParenL;
     var left = parseMaybeConditional(noIn);
     if (tokType.isAssign) {
-      if (metParenL !== oldParenL) raise(tokStart, "Assigning to rvalue");
       var node = startNodeAt(start);
       node.operator = tokVal;
       node.left = tokType === _eq ? toAssignable(left) : left;
       checkLVal(left);
       next();
       node.right = parseMaybeAssign(noIn);
-      // restore count of '(' so they are allowed in lvalue's defaults
-      metParenL = oldParenL;
       return finishNode(node, "AssignmentExpression");
     }
     return left;
@@ -2341,10 +2337,7 @@
     if (options.ecmaVersion >= 6) {
       if (eat(_bracketL)) {
         prop.computed = true;
-        // save & restore count of '(' so they are allowed in lvalue's computed props
-        var oldParenL = metParenL;
         prop.key = parseExpression();
-        metParenL = oldParenL;
         expect(_bracketR);
         return;
       } else {
diff --git a/test/tests-harmony.js b/test/tests-harmony.js
index e382754..d5cd958 100644
--- a/test/tests-harmony.js
+++ b/test/tests-harmony.js
@@ -3940,7 +3940,7 @@ test("[a, b] = [b, a]", {
   locations: true
 });
 
-test("({ responseText: text } = res)", {
+test("({ responseText: text }) = res", {
   type: "Program",
   body: [{
     type: "ExpressionStatement",
@@ -3985,13 +3985,13 @@ test("({ responseText: text } = res)", {
         type: "Identifier",
         name: "res",
         loc: {
-          start: {line: 1, column: 26},
-          end: {line: 1, column: 29}
+          start: {line: 1, column: 27},
+          end: {line: 1, column: 30}
         }
       },
       loc: {
-        start: {line: 1, column: 1},
-        end: {line: 1, column: 29}
+        start: {line: 1, column: 0},
+        end: {line: 1, column: 30}
       }
     },
     loc: {
@@ -13826,11 +13826,9 @@ testFail("[v] += ary", "Assigning to rvalue (1:0)", {ecmaVersion: 6});
 
 testFail("[2] = 42", "Assigning to rvalue (1:1)", {ecmaVersion: 6});
 
-testFail("({ obj:20 }) = 42", "Assigning to rvalue (1:13)", {ecmaVersion: 6});
-
-testFail("({ obj:20 } = 42)", "Assigning to rvalue (1:7)", {ecmaVersion: 6});
+testFail("({ obj:20 }) = 42", "Assigning to rvalue (1:7)", {ecmaVersion: 6});
 
-testFail("( { get x() {} } = 0 )", "Unexpected token (1:8)", {ecmaVersion: 6});
+testFail("( { get x() {} } ) = 0", "Unexpected token (1:8)", {ecmaVersion: 6});
 
 testFail("x \n is y", "Unexpected token (2:4)", {ecmaVersion: 6});
 
@@ -13850,9 +13848,9 @@ testFail("let default", "Unexpected token (1:4)", {ecmaVersion: 6});
 
 testFail("const default", "Unexpected token (1:6)", {ecmaVersion: 6});
 
-testFail("\"use strict\"; ({ v: eval } = obj)", "Assigning to eval in strict mode (1:20)", {ecmaVersion: 6});
+testFail("\"use strict\"; ({ v: eval }) = obj", "Assigning to eval in strict mode (1:20)", {ecmaVersion: 6});
 
-testFail("\"use strict\"; ({ v: arguments } = obj)", "Assigning to arguments in strict mode (1:20)", {ecmaVersion: 6});
+testFail("\"use strict\"; ({ v: arguments }) = obj", "Assigning to arguments in strict mode (1:20)", {ecmaVersion: 6});
 
 testFail("for (let x = 42 in list) process(x);", "Unexpected token (1:16)", {ecmaVersion: 6});
 
diff --git a/test/tests.js b/test/tests.js
index 1037330..172eb1f 100644
--- a/test/tests.js
+++ b/test/tests.js
@@ -403,7 +403,7 @@ test("(1 + 2 ) * 3", {
   preserveParens: true
 });
 
-testFail("(x) = 23", "Assigning to rvalue (1:4)");
+testFail("(x) = 23", "Assigning to rvalue (1:0)", { preserveParens: true });
 
 test("x = []", {
   type: "Program",
@@ -26883,7 +26883,7 @@ testFail("func() = 4",
          "Assigning to rvalue (1:0)");
 
 testFail("(1 + 1) = 10",
-         "Assigning to rvalue (1:8)");
+         "Assigning to rvalue (1:1)");
 
 testFail("1++",
          "Assigning to rvalue (1:0)");

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



More information about the Pkg-javascript-commits mailing list