Skip to content

Commit

Permalink
fix: detect unexpected ] in expression "[1,2][]"
Browse files Browse the repository at this point in the history
fixes #256
  • Loading branch information
6utt3rfly committed Jul 6, 2024
1 parent d0cf015 commit 70b8ea6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/jsep.js
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,9 @@ export class Jsep {
object: node,
property: this.gobbleExpression()
};
if (!node.property) {
this.throwError('Unexpected "' + this.char + '"');
}
this.gobbleSpaces();
ch = this.code;
if (ch !== Jsep.CBRACK_CODE) {
Expand Down
1 change: 1 addition & 0 deletions test/jsep.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import {testParser, testOpExpression, esprimaComparisonTest, resetJsepDefaults}
type: 'MemberExpression',
optional: true,
}, assert);
assert.throws(() => jsep('[1,2][]'), 'Unexpected "]"');
});

QUnit.test('Function Calls', function (assert) {
Expand Down

0 comments on commit 70b8ea6

Please sign in to comment.