Skip to content

Commit

Permalink
Merge f818984 into 2366c92
Browse files Browse the repository at this point in the history
  • Loading branch information
jugglinmike committed Jul 14, 2019
2 parents 2366c92 + f818984 commit 7a76712
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 2 deletions.
2 changes: 0 additions & 2 deletions src/jshint.js
Expand Up @@ -2634,12 +2634,10 @@ var JSHINT = (function() {
this.right = expression(context, 150);

if (!this.right) { // '!' followed by nothing? Give up.
/* istanbul ignore next */
quit("E041", this);
}

if (bang[this.right.id] === true) {
/* istanbul ignore next */
warning("W018", this, "!");
}
return this;
Expand Down
47 changes: 47 additions & 0 deletions tests/unit/parser.js
Expand Up @@ -280,6 +280,53 @@ exports.relations = function (test) {
run.test(code, {esnext: true});
run.test(code, {moz: true});

TestRun(test, "No suitable expression following logical NOT.")
.addError(1, 7, "Expected an identifier and instead saw ';'.")
.addError(1, 6, "Unrecoverable syntax error. (100% scanned).")
.test("void !;");

TestRun(test, "Logical NOT in combination with 'infix' operators.")
.addError(3, 6, "Confusing use of '!'.")
.addError(4, 6, "Confusing use of '!'.")
.addError(5, 6, "Confusing use of '!'.")
.addError(6, 6, "Confusing use of '!'.")
.addError(7, 6, "Confusing use of '!'.")
.addError(8, 6, "Confusing use of '!'.")
.addError(9, 6, "Confusing use of '!'.")
.addError(10, 6, "Confusing use of '!'.")
.addError(11, 6, "Confusing use of '!'.")
.addError(12, 6, "Confusing use of '!'.")
.addError(13, 6, "Confusing use of '!'.")
.addError(14, 6, "Confusing use of '!'.")
.addError(15, 6, "Confusing use of '!'.")
.test([
"void !'-';",
"void !'+';",
"void !(0 < 0);",
"void !(0 <= 0);",
"void !(0 == 0);",
"void !(0 === 0);",
"void !(0 !== 0);",
"void !(0 != 0);",
"void !(0 > 0);",
"void !(0 >= 0);",
"void !(0 + 0);",
"void !(0 - 0);",
"void !(0 * 0);",
"void !(0 / 0);",
"void !(0 % 0);",
]);

TestRun(test, "Logical NOT in combination with other unary operators.")
.addError(3, 6, "Confusing use of '!'.")
.addError(4, 6, "Confusing use of '!'.")
.test([
"void !'-';",
"void !'+';",
"void !+0;",
"void !-0;"
]);

test.done();
};

Expand Down

0 comments on commit 7a76712

Please sign in to comment.