Repository: jshint/jshint
Pull request #3537 (2021-02-21 03:31:20)

[[FIX]] Allow comma expression in MemberExpression

coveralls: 
[![Coverage Status](https://coveralls.io/builds/37300897/badge)](https://coveralls.io/builds/37300897)

Coverage remained the same at 100.0% when pulling **b4e55fe2fa1427ef52400ad117e5670a0bacbe6c on jugglinmike:comma-in-member** into **c13c5cc2be9e5ac6ea1355b47d84e818d8ca135f on jshint:master**.

coveralls: 
[![Coverage Status](https://coveralls.io/builds/37300897/badge)](https://coveralls.io/builds/37300897)

Coverage remained the same at 100.0% when pulling **b4e55fe2fa1427ef52400ad117e5670a0bacbe6c on jugglinmike:comma-in-member** into **c13c5cc2be9e5ac6ea1355b47d84e818d8ca135f on jshint:master**.

coveralls: 
[![Coverage Status](https://coveralls.io/builds/37300897/badge)](https://coveralls.io/builds/37300897)

Coverage remained the same at 100.0% when pulling **b4e55fe2fa1427ef52400ad117e5670a0bacbe6c on jugglinmike:comma-in-member** into **c13c5cc2be9e5ac6ea1355b47d84e818d8ca135f on jshint:master**.


Patch:
diff --git a/src/jshint.js b/src/jshint.js
index c868ff8e..aac08fa7 100644
--- a/src/jshint.js
+++ b/src/jshint.js
@@ -2364,11 +2364,14 @@ var JSHINT = (function() {
 
     return this;
   });
-  reserve("super", function() {
+
+  (function(superSymbol) {
+    superSymbol.rbp = 161;
+  })(reserve("super", function() {
     superNud.call(state.tokens.curr, this);
 
     return this;
-  });
+  }));
 
   assignop("=", "assign");
   assignop("+=", "assignadd");
@@ -2697,7 +2700,12 @@ var JSHINT = (function() {
     });
     if (mp) { return mp; }
 
+    var opening = state.tokens.next;
     var c = expression(context, 155), i;
+    if (!c.paren && c.rbp > 160) {
+      error("E024", opening, opening.value);
+    }
+
     if (c && c.id !== "function") {
       if (c.identifier) {
         switch (c.value) {
@@ -3268,7 +3276,7 @@ var JSHINT = (function() {
     return ret;
   });
 
-  application("=>");
+  application("=>").rbp = 161;
 
   infix("[", function(context, left, that) {
     var e, s, canUseDot;
@@ -3278,7 +3286,7 @@ var JSHINT = (function() {
       warning("W014", state.tokens.curr, state.tokens.curr.id);
     }
 
-    e = expression(context & ~prodParams.noin, 10);
+    e = expression(context & ~prodParams.noin, 0);
 
     if (e && e.type === "(string)") {
       if (!state.option.evil && (e.value === "eval" || e.value === "execScript")) {


Test patch:
diff --git a/tests/unit/core.js b/tests/unit/core.js
index a02be031..fe7e305c 100644
--- a/tests/unit/core.js
+++ b/tests/unit/core.js
@@ -249,6 +249,15 @@ exports.testNewNonNativeObject = function (test) {
   test.done();
 };
 
+exports.testNewArrowFn = function (test) {
+  TestRun(test)
+    .addError(1, 5, "Unexpected '('.")
+    .addError(1, 12, "Bad constructor.")
+    .addError(1, 12, "Missing '()' invoking a constructor.")
+    .test("new () => {};", {esversion: 6});
+
+  test.done();
+};
 
 /**
  * Test that JSHint allows `undefined` to be a function parameter.
diff --git a/tests/unit/parser.js b/tests/unit/parser.js
index 85ec6119..f58b73a9 100644
--- a/tests/unit/parser.js
+++ b/tests/unit/parser.js
@@ -1457,6 +1457,9 @@ exports.comma = function (test) {
       "}"
     ], { });
 
+  TestRun(test, "within MemberExpression")
+    .test("void [][0, 0];")
+
   test.done();
 };
 
@@ -7440,6 +7443,16 @@ exports.super.superCall = function (test) {
       "}"
     ], { esversion: 8 });
 
+  TestRun(test, "as operand to `new`")
+    .addError(3, 9, "Unexpected 'super'.")
+    .test([
+      "class C {",
+      "  constructor() {",
+      "    new super();",
+      "  }",
+      "}"
+    ], { esversion: 6 });
+
   test.done();
 };