Skip to content

Commit

Permalink
[[FIX]] Correct location for error
Browse files Browse the repository at this point in the history
  • Loading branch information
jugglinmike committed Mar 1, 2021
1 parent 916c230 commit e831188
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/jshint.js
Expand Up @@ -4772,7 +4772,7 @@ var JSHINT = (function() {
var tokens = destructuringPattern(context);
_.each(tokens, function(token) {
if (token.id) {
state.funct["(scope)"].addParam(token.id, token, "exception");
state.funct["(scope)"].addParam(token.id, token.token, "exception");
}
});
} else if (state.tokens.next.type !== "(identifier)") {
Expand Down
12 changes: 12 additions & 0 deletions tests/unit/core.js
Expand Up @@ -1784,6 +1784,18 @@ exports.testDefaultArguments = function (test) {
test.done();
};

exports.testEarlyCatchParam = function (test) {
TestRun(test)
.addError(2, 18, "'y' was used before it was declared, which is illegal for 'exception' variables.")
.test([
"try {",
"} catch ([x = y, y]) {",
"}"
], { esversion: 6 });

test.done();
};

exports.testDuplicateParamNames = function (test) {
var src = [
"(function() {",
Expand Down

0 comments on commit e831188

Please sign in to comment.