[Pkg-javascript-commits] [node-acorn-jsx] 246/484: Simplified name clash test.

Bastien Roucariès rouca at moszumanska.debian.org
Sat Aug 19 14:20:38 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 711d21ec5a0340f725e29ed462c89c0318d424f0
Author: Ingvar Stepanyan <me at rreverser.com>
Date:   Sat Jul 26 21:17:55 2014 +0300

    Simplified name clash test.
---
 acorn.js | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/acorn.js b/acorn.js
index 2cdecf4..e819209 100644
--- a/acorn.js
+++ b/acorn.js
@@ -1290,20 +1290,21 @@
   // either with each other or with an init property — and in
   // strict mode, init properties are also not allowed to be repeated.
 
-  function checkPropClash(prop, defaultKind, propHash) {
+  function checkPropClash(prop, propHash) {
     var key = prop.key, name;
     switch (key.type) {
       case "Identifier": name = key.name; break;
       case "Literal": name = String(key.value); break;
       default: return;
     }
-    var kind = prop.kind, other = propHash[name];
+    var kind = prop.kind || "init", other = propHash[name];
     if (other) {
-      var isGetSet = kind !== defaultKind;
-      if ((strict || isGetSet) && other[kind] || !(isGetSet ^ other[defaultKind]))
+      var isGetSet = kind !== "init";
+      if ((strict || isGetSet) && other[kind] || !(isGetSet ^ other.init))
         raise(key.start, "Redefinition of property");
     } else {
       other = propHash[name] = hash();
+      other.init = other.get = other.set = false;
     }
     other[kind] = true;
   }
@@ -2068,7 +2069,7 @@
         prop.shorthand = true;
       } else unexpected();
 
-      checkPropClash(prop, "init", propHash);
+      checkPropClash(prop, propHash);
       node.properties.push(finishNode(prop, "Property"));
     }
     return finishNode(node, "ObjectExpression");
@@ -2256,7 +2257,7 @@
         method.kind = "";
       }
       method.value = parseMethod(isGenerator);
-      checkPropClash(method, "", method.static ? staticMethodHash : methodHash);
+      checkPropClash(method, method.static ? staticMethodHash : methodHash);
       classBody.body.push(finishNode(method, "MethodDefinition"));
       eat(_semi);
     }

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