Skip to content

Commit

Permalink
Add regression test
Browse files Browse the repository at this point in the history
Effectively testing for this regression requires making the parser more
lenient (the test would otherwise have to specify many additional errors
that described unspecified parsing behavior in an invalid state).

In addition, remove assertoions from existing tests that suffer from
overspecified errors.
  • Loading branch information
jugglinmike committed Dec 16, 2014
1 parent 7430ee5 commit 41443d6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
8 changes: 8 additions & 0 deletions src/jshint.js
Expand Up @@ -1451,6 +1451,14 @@ var JSHINT = (function () {
}
} else {
error("E030", state.tokens.next, state.tokens.next.value);

// The token should be consumed after a warning is issued so the parser
// can continue as though an identifier were found. The semicolon token
// should not be consumed in this way so that the parser interprets it as
// a statement delimeter;
if (state.tokens.next.id !== ";") {
advance();
}
}
}

Expand Down
14 changes: 8 additions & 6 deletions tests/unit/parser.js
Expand Up @@ -821,8 +821,6 @@ exports["destructuring var in function scope"] = function (test) {
.addError(9, "'a' is already defined.")
.addError(9, "'bar' is already defined.")
.addError(10, "Expected an identifier and instead saw '1'.")
.addError(10, "Expected ',' and instead saw '1'.")
.addError(10, "Expected an identifier and instead saw ']'.")
.addError(11, "Expected ',' and instead saw ';'.")
.addError(11, "'a' is already defined.")
.addError(11, "'b' is already defined.")
Expand Down Expand Up @@ -997,8 +995,6 @@ exports["destructuring var errors"] = function (test) {

TestRun(test)
.addError(9, "Expected an identifier and instead saw '1'.")
.addError(9, "Expected ',' and instead saw '1'.")
.addError(9, "Expected an identifier and instead saw ']'.")
.addError(10, "Expected ',' and instead saw ';'.")
.addError(11, "Expected ']' to match '[' from line 11 and instead saw ';'.")
.addError(11, "Missing semicolon.")
Expand Down Expand Up @@ -1218,8 +1214,6 @@ exports["destructuring const errors"] = function (test) {
.addError(2, "const 'b' has already been declared.")
.addError(2, "const 'c' has already been declared.")
.addError(3, "Expected an identifier and instead saw '1'.")
.addError(3, "Expected ',' and instead saw '1'.")
.addError(3, "Expected an identifier and instead saw ']'.")
.addError(4, "Expected ',' and instead saw ';'.")
.addError(5, "Expected ']' to match '[' from line 5 and instead saw ';'.")
.addError(5, "Missing semicolon.")
Expand Down Expand Up @@ -3739,6 +3733,14 @@ exports["default arguments in fat arrow functions"] = function (test) {
test.done();
};

exports["expressions in place of arrow function parameters"] = function (test) {
TestRun(test)
.addError(1, "Expected an identifier and instead saw '1'.")
.test("(1) => {};", { expr: true, esnext: true });

test.done();
};

var conciseMethods = exports.conciseMethods = {};

conciseMethods.basicSupport = function (test) {
Expand Down

0 comments on commit 41443d6

Please sign in to comment.